Scheduling infrastructure for absolutely everyone.
fix: failing tests during DST transition (#19862)
Vijayf8af9dc17ed7
diff --git a/packages/features/bookings/lib/handleNewBooking/test/complex-schedules.test.ts b/packages/features/bookings/lib/handleNewBooking/test/complex-schedules.test.tsindex 22f0dfd487e..91910bc00d2 100644--- a/packages/features/bookings/lib/handleNewBooking/test/complex-schedules.test.ts+++ b/packages/features/bookings/lib/handleNewBooking/test/complex-schedules.test.ts@@ -56,19 +56,35 @@ describe("handleNewBooking", () => {});// Using .endOf("day") here to ensure our date doesn't change when we set the time zone- const startDateTimeOrganizerTz = dayjs(plus1DateString)+ let startDateTimeOrganizerTz = dayjs(plus1DateString).endOf("day").tz(newYorkTimeZone).hour(23).minute(0).second(0);- const endDateTimeOrganizerTz = dayjs(plus1DateString)+ let endDateTimeOrganizerTz = dayjs(plus1DateString).endOf("day").tz(newYorkTimeZone).startOf("day").add(1, "day");+ const endUtcOffset = Math.abs(endDateTimeOrganizerTz.utcOffset());+ const startUtcOffset = Math.abs(startDateTimeOrganizerTz.utcOffset());+ //on DST transition day the utc offsets are unequal+ if (startUtcOffset !== endUtcOffset) {+ if (endUtcOffset > startUtcOffset) {+ // -5:00 to -4:00 transition+ endDateTimeOrganizerTz = endDateTimeOrganizerTz.subtract(+ endUtcOffset - startUtcOffset,+ "minutes"+ );+ } else {+ // -4:00 to -5:00 transition+ startDateTimeOrganizerTz = startDateTimeOrganizerTz.add(startUtcOffset - endUtcOffset, "minutes");+ }+ }+const schedule = {name: "4:00PM to 11:59PM in New York",availability: [diff --git a/packages/features/bookings/lib/handleNewBooking/test/date-overrides.test.ts b/packages/features/bookings/lib/handleNewBooking/test/date-overrides.test.tsindex 571706da2e2..ea3c7cfc991 100644--- a/packages/features/bookings/lib/handleNewBooking/test/date-overrides.test.ts+++ b/packages/features/bookings/lib/handleNewBooking/test/date-overrides.test.ts@@ -221,19 +221,35 @@ describe("handleNewBooking", () => {});// Using .endOf("day") here to ensure our date doesn't change when we set the time zone- const startDateTimeOrganizerTz = dayjs(plus1DateString)+ let startDateTimeOrganizerTz = dayjs(plus1DateString).endOf("day").tz(newYorkTimeZone).hour(23).minute(0).second(0);- const endDateTimeOrganizerTz = dayjs(plus1DateString)+ let endDateTimeOrganizerTz = dayjs(plus1DateString).endOf("day").tz(newYorkTimeZone).startOf("day").add(1, "day");+ const endUtcOffset = Math.abs(endDateTimeOrganizerTz.utcOffset());+ const startUtcOffset = Math.abs(startDateTimeOrganizerTz.utcOffset());+ //on DST transition day the utc offsets are unequal+ if (startUtcOffset !== endUtcOffset) {+ if (endUtcOffset > startUtcOffset) {+ // -5:00 to -4:00 transition+ endDateTimeOrganizerTz = endDateTimeOrganizerTz.subtract(+ endUtcOffset - startUtcOffset,+ "minutes"+ );+ } else {+ // -4:00 to -5:00 transition+ startDateTimeOrganizerTz = startDateTimeOrganizerTz.add(startUtcOffset - endUtcOffset, "minutes");+ }+ }+const overrideSchedule = {name: "11:00PM to 11:59PM in New York",availability: [