Skip to content

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

Closed

Description

@smith-xyz

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!

Activity

  1. mscdex commented on May 5, 2022

    @mscdex
    Contributor

    FWIW it works in node v18.x

  2. LiviaMedeiros commented on May 5, 2022

    @LiviaMedeiros
    Member

    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

  3. smith-xyz commented on May 6, 2022

    @smith-xyz
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions