From 62bd0986c0ff49674d42daee4ff1fdc7074f30e4 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Wed, 17 Jun 2026 06:28:36 +0000 Subject: [PATCH] Intl: accept legacy IANA primary zones (CET, CST6CDT, EET, EST5EDT, MET, MST7MDT, PST8PDT, WET) These identifiers are first-class `Zone`s in the IANA `etcetera` file (not backward links), so they are primary IANA time zone identifiers. ICU reports them as canonical primaries, but `isValidTimeZoneNameFromICUTimeZone` dropped every non-`/` name except `UTC`/`GMT`, so `new Intl.DateTimeFormat(undefined, { timeZone: "CET" })` threw `RangeError` on Linux/Windows. macOS was unaffected (system libicucore has a different canonical table). Fixes oven-sh/bun#30618 --- Source/JavaScriptCore/runtime/IntlObject.cpp | 21 ++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Source/JavaScriptCore/runtime/IntlObject.cpp b/Source/JavaScriptCore/runtime/IntlObject.cpp index 7267db91e47e..6e6bb188de0d 100644 --- a/Source/JavaScriptCore/runtime/IntlObject.cpp +++ b/Source/JavaScriptCore/runtime/IntlObject.cpp @@ -1951,10 +1951,23 @@ static bool isValidTimeZoneNameFromICUTimeZone(StringView timeZoneName) return false; if (timeZoneName.startsWith("Etc/"_s)) return true; - // IANA time zone names include '/'. Some of them are not including, but it is in backward links. - // And ICU already resolved these backward links. - if (!timeZoneName.contains('/')) - return timeZoneName == "UTC"_s || timeZoneName == "GMT"_s; + // IANA time zone names usually include '/'. The following legacy identifiers + // are first-class `Zone`s in the IANA `etcetera` file (not backward links), + // so they are primary IANA zones and must be treated as valid: + // CET, CST6CDT, EET, EST5EDT, MET, MST7MDT, PST8PDT, WET + // plus UTC/GMT which are always valid. + if (!timeZoneName.contains('/')) { + return timeZoneName == "UTC"_s + || timeZoneName == "GMT"_s + || timeZoneName == "CET"_s + || timeZoneName == "CST6CDT"_s + || timeZoneName == "EET"_s + || timeZoneName == "EST5EDT"_s + || timeZoneName == "MET"_s + || timeZoneName == "MST7MDT"_s + || timeZoneName == "PST8PDT"_s + || timeZoneName == "WET"_s; + } return true; }