vvo / tzdb

🕰 Simplified, grouped and always up to date list of time zones, with major cities

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UTC timezone's name does not match README.md

alexkuc opened this issue · comments

According to readme, when using parameter includeUtc, utc time zone can be found under UTC:

tzdb/README.md

Lines 35 to 37 in 23081e3

// You can also provide an optional parameter to include UTC in the result.
// This adds a time zone with the name "UTC" and a fixed offset of 0.
const timeZonesWithUtc = getTimeZones({ includeUtc: true });

However, through trial and error, I found out it is actually Etc/UTC and not just UTC:

https://codesandbox.io/s/suspicious-david-945pw3?file=/src/App.tsx

Is it supposed to be UTC or Etc/UTC? If it's the second, I can submit PR to update docs.

I'm not an expert in this package, but I do know that ECMAScript names the UTC time zone differently than the IANA Time Zone Database.

In the IANA source data, the canonical name is Etc/UTC. But ECMAScript has decided, for brevity and clarity's sake, that UTC will be the canonical name for this time zone when used in ECMAScript. To illustrate:

new Intl.DateTimeFormat('en', { timeZone: 'Etc/UTC' }).resolvedOptions().timeZone;
// => 'UTC'

So, depending on the use case, either Etc/UTC or UTC may be used. If the goal is to match how JS code works (both Intl.DateTimeFormat and the upcoming Temporal API) then use UTC. If the goal is to match the IANA TZDB, then use Etc/UTC. Both represent the same time zone, the only difference is which string is the canonical name.

@justingrant

So, depending on the use case, either Etc/UTC or UTC may be used.

Either way docs should be updated because currently, README.md says UTC whereas actual code returns Etc/UTC