Fixing DST issues for recurring reservations

This commit is contained in:
Collin Duncan 2024-03-28 18:02:33 +01:00
parent 11dc49e865
commit 7d6b45032b
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View file

@ -36,7 +36,7 @@ const dayjsTz = (
date?: string | number | Date | dayjs.Dayjs | null | undefined, date?: string | number | Date | dayjs.Dayjs | null | undefined,
format?: string, format?: string,
) => { ) => {
return dayjs(date, format).tz() return dayjs(date, format).tz('Europe/Amsterdam')
} }
export default dayjsTz export default dayjsTz

View file

@ -12,7 +12,7 @@ describe('recurringReservations.entity', () => {
dayOfWeek: 2, dayOfWeek: 2,
}) })
const reservation = rr.createReservationInAdvance(7) const reservation = rr.createReservationInAdvance(7)
expect(reservation.dateRangeStart).toEqual(dayjs('2024-01-09T18:30')) expect(reservation.dateRangeStart).toEqual(dayjs('2024-01-09T17:30Z'))
}) })
it('should create reservation at same time in 7 days (DST --> NDST)', async () => { it('should create reservation at same time in 7 days (DST --> NDST)', async () => {
@ -24,7 +24,7 @@ describe('recurringReservations.entity', () => {
dayOfWeek: 4, dayOfWeek: 4,
}) })
const reservation = rr.createReservationInAdvance(7) const reservation = rr.createReservationInAdvance(7)
expect(reservation.dateRangeStart).toEqual(dayjs('2024-04-04T18:30')) expect(reservation.dateRangeStart).toEqual(dayjs('2024-04-04T16:30Z'))
}) })
it('should create reservation at same time in 7 days (NDST --> DST)', async () => { it('should create reservation at same time in 7 days (NDST --> DST)', async () => {
@ -36,7 +36,7 @@ describe('recurringReservations.entity', () => {
dayOfWeek: 4, dayOfWeek: 4,
}) })
const reservation = rr.createReservationInAdvance(7) const reservation = rr.createReservationInAdvance(7)
expect(reservation.dateRangeStart).toEqual(dayjs('2024-10-31T18:30')) expect(reservation.dateRangeStart).toEqual(dayjs('2024-10-31T17:30Z'))
}) })
}) })
}) })