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
:
Lines 35 to 37 in 23081e3
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.
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