-
Notifications
You must be signed in to change notification settings - Fork 837
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
Extend tz.names() to include more information #760
Comments
if this hasn't been worked on, I can take a look into placing this enhancement |
This is exactly what I am looking for! The issue with showing just a sorted list of IANA timezones is that user may not know what to pick for their desired location. For example, a user in Salt Lake City, UT may have no clue that they should pick America/Denver. However if we sort by timezone offsets, they can get a sense by looking at the GMT offset:
Also knowing their own offset, they can quickly scroll the the right place. I know that there is an issue with offsets because they are relative to a specific time, but showing the offset at current time gives us a good solution for 80% of the use cases. Of course, having the ability to show a more readable name would be a bonus. P.S. Is there a way to get an array of all zone objects? #43 mentioned that there is a global variable called |
After reading the docs again, I was able to display timezones sorted by offsets. The trick was to get a zone object and then call
|
The IANA time zone database doesn't contain long-form names for time zones as shown in the opening screenshot, so getting that data into Moment Timezone wouldn't be possible just using the existing data source. The Unicode Common Locale Data Repository (CLDR) is the best source for this kind of information. It contains mappings between IANA ids (e.g. |
Thank you @gilmoreorless for excellent explanation. |
I'd suggest even extending this a little bit more so that what gets returned is an array of objects, with each object containing the offset, the TZ database name, a readable name and as a bonus, maybe even an array with the countries that are in time timezone. This way, we could use the method to populate fields like this:
The text was updated successfully, but these errors were encountered: