Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🐛 Fall back when Intl.supportedValuesOf is missing in the time zone picker
Luke Vellaa459cf670da4
diff --git a/apps/web/src/components/time-zone-picker/time-zone-select.test.tsx b/apps/web/src/components/time-zone-picker/time-zone-select.test.tsxindex 83dfd31e2..58b275ebe 100644--- a/apps/web/src/components/time-zone-picker/time-zone-select.test.tsx+++ b/apps/web/src/components/time-zone-picker/time-zone-select.test.tsx@@ -1,5 +1,6 @@import userEvent from "@testing-library/user-event";import { describe, expect, it } from "vitest";+import { getBrowserTimeZone } from "@/lib/utils/date-time-utils";import { toRuntimeCanonicalIanaId } from "@/lib/utils/timezone-schema";import { render, screen, within } from "@/test/test-utils";@@ -229,3 +230,20 @@ describe("stored value round trip", () => {expect(onValueChange).toHaveBeenCalledWith("Asia/Kolkata");});});++describe("getAllTimezoneIds without Intl.supportedValuesOf", () => {+ it("falls back to the curated set plus the runtime zone", () => {+ const original = Intl.supportedValuesOf;+ // @ts-expect-error simulating an engine that predates the API+ delete Intl.supportedValuesOf;+ try {+ const ids = getAllTimezoneIds();+ expect(ids).toEqual(+ expect.arrayContaining(Array.from(curatedTimezoneIds)),+ );+ expect(ids).toContain(getBrowserTimeZone());+ } finally {+ Intl.supportedValuesOf = original;+ }+ });+});diff --git a/apps/web/src/components/time-zone-picker/timezone-data.ts b/apps/web/src/components/time-zone-picker/timezone-data.tsindex a50615ac6..c2ed8222b 100644--- a/apps/web/src/components/time-zone-picker/timezone-data.ts+++ b/apps/web/src/components/time-zone-picker/timezone-data.ts@@ -1,11 +1,25 @@+import { getBrowserTimeZone } from "@/lib/utils/date-time-utils";import {getIanaIdAliases,normalizeLegacyIanaId,toRuntimeCanonicalIanaId,} from "@/lib/utils/timezone-schema";+/**+ * Engines without `Intl.supportedValuesOf` (Chrome < 99, Safari < 15.4 and+ * forks built on them) get the curated set plus their own zone, instead of a+ * throw at module scope that takes down every page importing the picker.+ */export function getAllTimezoneIds(): string[] {- return Intl.supportedValuesOf("timeZone");+ if (typeof Intl.supportedValuesOf === "function") {+ return Intl.supportedValuesOf("timeZone");+ }+ const ids = new Set(curatedTimezoneIds);+ const ownZone = getBrowserTimeZone();+ if (ownZone) {+ ids.add(ownZone);+ }+ return Array.from(ids);}export function getCityFromTimezoneId(id: string): string {