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.DateTimeFormat - "Pacific/Kanton" is invalid time zone #42980

Closed
smith-xyz opened this issue May 5, 2022 · 3 comments
Closed

Intl.DateTimeFormat - "Pacific/Kanton" is invalid time zone #42980

smith-xyz opened this issue May 5, 2022 · 3 comments

Comments

@smith-xyz
Copy link

smith-xyz commented May 5, 2022

Version

v16.13.2

Platform

21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

When providing Pacific/Kanton as a timezone to Intl, it is returned as invalid:

try {
  new Intl.DateTimeFormat("en-US", {
    timeZone: "Pacific/Kanton",
  });
} catch (err) {
  console.error(err);
}

How often does it reproduce? Is there a required condition?

Seems to consistently throw an error

What is the expected behavior?

Should be considered a valid time zone since IANA lists it as an active time zone.

What do you see instead?

An error is thrown for an invalid time zone provided:

RangeError: Invalid time zone specified: Pacific/Kanton
    at new DateTimeFormat (<anonymous>)
    at Object.<anonymous> (/Code/ssmith-sandbox/dist/index.js:3:5)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Additional information

I may just be missing something in regards to why this tz is invalid, but found this interesting when I stumbled on it recently. Would gladly like to know!

@mscdex
Copy link
Contributor

mscdex commented May 5, 2022

FWIW it works in node v18.x

@LiviaMedeiros
Copy link
Contributor

Seems to be added since ICU v70.1

process.versions.node; // 14.17.6
process.versions.icu; // 70.1 (system ver. here)
new Intl.DateTimeFormat("en-US", { timeZone: "Pacific/Kanton", }); // DateTimeFormat [Object] {}

Refs: unicode-org/icu@3a601a8

@smith-xyz
Copy link
Author

@mscdex - yep works in v17.x as well it seems. So seems its just v16 and prior.

@LiviaMedeiros ahh awesome thanks for tracking it down, and it looks like the dep was update and it works on v16.15.0 : #40658

Thank you both!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants