Skip to content

Commit

Permalink
Merge pull request #34 from octotravel/fix/availability-helper
Browse files Browse the repository at this point in the history
Fix/availability helper
  • Loading branch information
dominikchrastek authored Nov 22, 2024
2 parents c1a65dd + 3f3d2df commit 7e7d7ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@octocloud/core",
"version": "1.0.62",
"version": "1.0.63",
"license": "ISC",
"author": "",
"exports": {
Expand Down
9 changes: 8 additions & 1 deletion src/models/AvailabilityHelper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { Availability } from '@octocloud/types';
import { NoAvailabilityError } from './Error';
import { DateHelper } from './DateHelper';

export class AvailabilityHelper {
public static checkAvailability = (availabilities: Availability[], dateString: string): Availability => {
const availability = availabilities.find((availability) => availability.localDateTimeStart === dateString) ?? null;
const availability =
availabilities.find((availability) => {
if (availability.allDay) {
return DateHelper.getDate(availability.localDateTimeStart) === DateHelper.getDate(dateString);
}
return availability.localDateTimeStart === dateString;
}) ?? null;
if (availability === null) {
throw new NoAvailabilityError();
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/__tests__/DateHelper.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DateHelper } from '../DateHelper';
import { describe, expect, it } from 'vitest';
import { DateHelper } from '../DateHelper';

describe('DateHelper', () => {
const date = '2023-12-01';
Expand Down

0 comments on commit 7e7d7ee

Please sign in to comment.