Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intl.supportedValuesOf('timeZone') for UTC, Etc/GMT*, and other non-contintent/non-ocean time zone identifiers #778

Open
justingrant opened this issue Apr 27, 2023 · 3 comments
Labels
c: datetime Component: dates, times, timezones s: discuss Status: TG2 must discuss to move forward

Comments

@justingrant
Copy link
Contributor

justingrant commented Apr 27, 2023

As part of work on proposal-canonical-tz, I noticed that JS engines have very different results from Intl.supportedValuesOf('timeZone') for time zones that are not associated with a continent or ocean.

V8 does not return any of these zones. Safari returns only one: UTC. Firefox returns 40 zones, including "UTC", Etc/ zones like "Etc/GMT+11", and a few others like "EST" and "CET".

Should the 402 spec be more prescriptive about what kinds of canonical time zone identifiers should vs. should not be returned by this API?

Intl.supportedValuesOf('timeZone').filter(z => !['Asia', 'Africa', 'Europe', 'Australia', 'America', 'Antarctica', 'Atlantic', 'Pacific', 'Indian', 'Arctic'].some(c => z.startsWith(c)))

// => Chrome: []
// => Safari: ["UTC"]
// => Firefox: [
  "CET",
  "CST6CDT",
  "EET",
  "EST",
  "EST5EDT",
  "Etc/GMT+1",
  "Etc/GMT+10",
  "Etc/GMT+11",
  "Etc/GMT+12",
  "Etc/GMT+2",
  "Etc/GMT+3",
  "Etc/GMT+4",
  "Etc/GMT+5",
  "Etc/GMT+6",
  "Etc/GMT+7",
  "Etc/GMT+8",
  "Etc/GMT+9",
  "Etc/GMT-1",
  "Etc/GMT-10",
  "Etc/GMT-11",
  "Etc/GMT-12",
  "Etc/GMT-13",
  "Etc/GMT-14",
  "Etc/GMT-2",
  "Etc/GMT-3",
  "Etc/GMT-4",
  "Etc/GMT-5",
  "Etc/GMT-6",
  "Etc/GMT-7",
  "Etc/GMT-8",
  "Etc/GMT-9",
  "Factory",
  "HST",
  "MET",
  "MST",
  "MST7MDT",
  "PST8PDT",
  "UTC",
  "WET"
]
@sffc sffc moved this from Priority Issues to Previously Discussed in ECMA-402 Meeting Topics May 4, 2023
@anba
Copy link
Contributor

anba commented May 17, 2023

Intl.supportedValuesOf calls AvailableCanonicalTimeZones, which computes the result based on all supported time zone and link names.

  • CET, EET, MET, and WET are defined time zone zones in the europe file.
  • CST6CDT, EST, EST5EDT, HST, MST, MST7MDT, and PST8PDT are defined as time zone zones in the northamerica file.
  • Etc/GMT-14 to Etc/GMT+12 are defined as time zone zones in the etcetera file.
  • Etc/UTC and Etc/GMT are also defined in the etcetera file. Both are canonicalised to UTC in CanonicalizeTimeZoneName.
  • Factory is from the factory file. IIRC it's just a placeholder time zone, but because it's supported in all browsers (new Intl.DateTimeFormat("en", {timeZone: "Factory"}).resolvedOptions().timeZone), I've never removed the support for it.

So all additional time zones returned by Firefox are correct and should also be returned by the other browsers, as long as the time zone id is supported by Intl.DateTimeFormat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: datetime Component: dates, times, timezones s: discuss Status: TG2 must discuss to move forward
Projects
ECMA-402 Meeting Topics
Previously Discussed
Development

No branches or pull requests

3 participants