Open alexkuc opened 1 year ago
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
According to readme, when using parameter
includeUtc
, utc time zone can be found underUTC
:https://github.com/vvo/tzdb/blob/23081e3be1c2f44fb6187455ed7880dedc81adeb/README.md?plain=1#L35-L37
However, through trial and error, I found out it is actually
Etc/UTC
and not justUTC
:https://codesandbox.io/s/suspicious-david-945pw3?file=/src/App.tsx
Is it supposed to be
UTC
orEtc/UTC
? If it's the second, I can submit PR to update docs.