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

UTC timezone's name does not match README.md #272

Open
alexkuc opened this issue Oct 27, 2022 · 2 comments
Open

UTC timezone's name does not match README.md #272

alexkuc opened this issue Oct 27, 2022 · 2 comments

Comments

@alexkuc
Copy link

alexkuc commented Oct 27, 2022

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.

@justingrant
Copy link

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.

@alexkuc
Copy link
Author

alexkuc commented Mar 5, 2023

@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

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

2 participants