From a156a784a1a5da104232cf5d10af7ffbb27ace91 Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Mon, 25 Jul 2022 22:45:34 +0100 Subject: [PATCH] Fixes Atlantic/Azores blank results (#3516) --- apps/web/components/booking/pages/AvailabilityPage.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsx index 15615d1613..90d683ac3a 100644 --- a/apps/web/components/booking/pages/AvailabilityPage.tsx +++ b/apps/web/components/booking/pages/AvailabilityPage.tsx @@ -166,14 +166,18 @@ const SlotPicker = ({ // Etc/GMT is not actually a timeZone, so handle this select option explicitly to prevent a hard crash. if (timeZone === "Etc/GMT") { - setBrowsingDate(dayjs.utc(month).startOf("month")); + setBrowsingDate(dayjs.utc(month).set("date", 1).set("hour", 0).set("minute", 0).set("second", 0)); if (date) { setSelectedDate(dayjs.utc(date)); } } else { - setBrowsingDate(dayjs(month).tz(timeZone, true).startOf("month")); + // Set the start of the month without shifting time like startOf() may do. + setBrowsingDate( + dayjs.tz(month, timeZone).set("date", 1).set("hour", 0).set("minute", 0).set("second", 0) + ); if (date) { - setSelectedDate(dayjs(date).tz(timeZone, true)); + // It's important to set the date immediately to the timeZone, dayjs(date) will convert to browsertime. + setSelectedDate(dayjs.tz(date, timeZone)); } } }, [router.isReady, month, date, timeZone]);