diff --git a/src/date-utils.ts b/src/date-utils.ts index 25e9363..ffcd098 100644 --- a/src/date-utils.ts +++ b/src/date-utils.ts @@ -21,6 +21,10 @@ export function firstOfWeekdayAfterDate(weekday: Weekday, refDate: Date) { export function fixedDate(date: Date) { const d = new Date(date); + d.setMilliseconds(0); + d.setSeconds(0); + d.setMinutes(0); + d.setHours(0); d.setMinutes(-d.getTimezoneOffset()); return d; } diff --git a/tests/swedish-holidays.test.ts b/tests/swedish-holidays.test.ts index cb41762..456a0bb 100644 --- a/tests/swedish-holidays.test.ts +++ b/tests/swedish-holidays.test.ts @@ -19,10 +19,15 @@ test('Should throw an error if year is out of range', () => { }); test('isPublicHoliday should be true for sundays', () => { - const saturdayIsNotPublicHoliday = isPublicHoliday(new Date('2021-11-13')); - const sundayIsPublicHoliday = isPublicHoliday(new Date('2021-11-14')); - const mondayIsNotPublicHoliday = isPublicHoliday(new Date('2021-11-15')); + const saturdayIsNotPublicHoliday = isPublicHoliday(new Date('2021-11-13T01:23:45.678Z')); + const sundayIsPublicHoliday = isPublicHoliday(new Date('2021-11-14T01:23:45.678Z')); + const mondayIsNotPublicHoliday = isPublicHoliday(new Date('2021-11-15T01:23:45.678Z')); assert.strictEqual(saturdayIsNotPublicHoliday, false); assert.strictEqual(sundayIsPublicHoliday, true); assert.strictEqual(mondayIsNotPublicHoliday, false); }); + +test('isPublicHoliday should be true for christmas day', () => { + const christmas = isPublicHoliday(new Date('2021-12-25T01:23:45.678Z')); + assert.strictEqual(christmas, true); +});