Fix/incorrect timezone on booking success (#7544)

* set the selected timezone to formatToLocalizedTimezone function

* remove console.logs
This commit is contained in:
Efraín Rochín authored and GitHub committed 2023-03-06 23:12:43 +00:00
1 parent 69808bb9a4
commit 33f35e77fd
2 files changed
+5 -5

No files matched your search

+2 -1
View File
@@ -75,12 +75,13 @@ export const formatToLocalizedTime = (
export const formatToLocalizedTimezone = (
date: Date | Dayjs,
locale: string | undefined = undefined,
timeZone: Intl.DateTimeFormatOptions["timeZone"],
timeZoneName: Intl.DateTimeFormatOptions["timeZoneName"] = "long"
) => {
// Intl.DateTimeFormat doesn't format into a timezone only, so we must
// formatToParts() and return the piece we want
const theDate = date instanceof dayjs ? (date as Dayjs).toDate() : (date as Date);
return Intl.DateTimeFormat(locale, { timeZoneName })
return Intl.DateTimeFormat(locale, { timeZoneName, timeZone })
.formatToParts(theDate)
.find((d) => d.type == "timeZoneName")?.value;
};