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

moment.tz.zonesForCountry does not return all timezones for a country #1118

Open
jgtestw opened this issue Oct 1, 2024 · 2 comments
Open

Comments

@jgtestw
Copy link

jgtestw commented Oct 1, 2024

Environment:
Moment Version: 2.30.1
Moment Timezone Version: 0.5.45-2024a
System: https://momentjs.com/ developer console

console.log(moment.tz.zonesForCountry("AU"));

This is supposed to return all timezones for Australia, but it's missing some. For example "Australia/Canberra".

This is what it returns:

['Antarctica/Macquarie', 'Australia/Adelaide', 'Australia/Brisbane', 'Australia/Broken_Hill', 'Australia/Darwin', 'Australia/Eucla', 'Australia/Hobart', 'Australia/Lindeman', 'Australia/Lord_Howe', 'Australia/Melbourne', 'Australia/Perth', 'Australia/Sydney']

But where's "Australia/Canberra"?

In general, it seems that zonesForCountry does not return "link" records of the IANA database. A link record, as far as I understand, is a record that itself does not have an offset, but is tied to the offset of another timezone. In the case of "Australia/Canberra" that other timezone is "Australia/Sydney".

@gilmoreorless
Copy link
Member

You're correct that it doesn't return zone links, only primary zone records. This is because the list is generated by parsing the tzdb's zone.tab and zone1970.tab files. These source files don't list any links, because the point of the files is to list only the active, primary zones for a region.

Links are not primary zones, they're just aliases. Sometimes the aliases are because there used to be a primary zone of that name, but it's been merged into another zone. Sometimes it's a simple rename (one of the most recent was Europe/Kiev to Europe/Kyiv). But either way, the links are mostly there just for backwards compatibility.

Out of curiosity, why do you want Australia/Canberra to be in the list, when it's been an alias of Australia/Sydney for a long time?

@jgtestw
Copy link
Author

jgtestw commented Oct 1, 2024

Because we have a dropdown of timezones for Australia. One of our clients passed "Australia/Canberra", and because it wasn't in the dropdown, it caused issues. I am just going to obtain the list of timezones for Australia from another source (hardcoded list)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants