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

A simple list of time zones. #499

Closed
GMeulendyks opened this issue May 31, 2017 · 5 comments
Closed

A simple list of time zones. #499

GMeulendyks opened this issue May 31, 2017 · 5 comments

Comments

@GMeulendyks
Copy link

GMeulendyks commented May 31, 2017

Hey guys,

I'm looking to get a simple list of zone objects in packed format. Truthfully when I look at the list outlined here: https://github.com/moment/moment-timezone/blob/develop/data/packed/latest.json the list is just absurdly large and contains many duplicate time zones with different names. I don't want to confuse anyone who wants to pick a simple timezone from a drop down and be done.

Therefore, I would like to request a simple list of Microsoft time zones outlined here: https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx in zone objects packed format (exactly like the list defined in the latest.json). I understand that it is possible to build a list of these objects myself, but looking at the documentation here: https://momentjs.com/timezone/docs/#/data-formats/packed-format/ I really have no idea how to determine Offset Map, Abbr/Offset Index, and Timestamp Diffs.

Would anyone else benefit from a list like this?

@mattjohnsonpint
Copy link
Contributor

Yes, there are lots of folks that could benefit from a simplified list of time zones for time zone selection purposes.

However, a few things:

  • We won't do Microsoft time zones here (see Moment.cs class for C# .Net #130, Provide support for Windows formatted timezones #281, Microsoft Time Zone IDs #355, Add support for standard names #462) If you must use Microsoft time zones on the server (for example, because you're already locked in to the TimeZoneInfo object in .NET), then use my TimeZoneConverter library to convert from IANA to Microsoft in your .NET code. (But preferably use Noda-Time in your .NET code to work with IANA time zones.)

  • The link you gave to MSDN should die an awful death. It is for Windows Embedded POS 1.1, which had "index numbers" on the time zones. There is no MSDN page that lists Microsoft IDs because the page would have to be maintained as time zones change. For current Microsoft IDs, either reference CLDR, or call tzutil /l on the command line.

  • In general, Microsoft time zones are not specific enough to cover all use cases. For example, there is one Microsoft time zone that covers "Dublin, Edinburgh, Lisbon, London". There are 9 different IANA time zones that are roughly mapped to this zone in the CLDR because they currently use the same time zone rules. But if you go back into history, you'll find they didn't always do so. If one cares about the differences, then one has to keep them separated. Your app might not care, but someone else's could.

Ideally, one would never pick "America/Los_Angeles", but would instead pick "Pacific Time", after first picking "United States". But even then, there's the problem of localization. How do I get "Pacific Time" in English but "heure du Pacifique" in French? That's another place where CLDR comes in.

However, even then they aren't specific enough, because "Mountain Time" could mean America/Denver, or it could mean America/Phoenix (which doesn't have DST). So one has to programatically decide to concatenate to make "Mountain Time" and "Mountain Time (Arizona)"

And there are even more edge cases....

I've already tackled this from a .NET perspective, with my TimeZoneNames library. There's even a demo you can try out here that shows how a threshold date can be used to apply the type of context I spoke of earlier. You're welcome to rip off any of my code.

What's probably needed is a pure JavaScript version of this. I'll work on that some other time, or maybe someone else will beat me to it. :) Anyway, it can't go here because we would need all of the localized time zone names from CLDR, which would make the size of this library huge.

There is some work started in PR #175 that would at least let you limit by country, but it needs some revision before it can be merged.

In the meantime, the best we can offer is moment.tz.names().

@alfonmga
Copy link

alfonmga commented Jan 6, 2019

Is there any way to get a simplified list of time zones currently?

I'm looking for a simplified list similar to this one: https://gist.github.com/alfonmga/0e460fe8cbebce1e2015bad1e93f07b7

I'm not sure at all how I could achieve a similar result using Moment Timezone.
momentTimezone.tz.names() is returning 592 time zones, this is huge.

@vvo
Copy link

vvo commented Jun 17, 2020

Hey, I recently struggled with that too while willing to build a Google calendar like time zone selector:
image.

Google calendar has 352 time zones (June 2020) and I believe they are mostly all necessary (you can't fail time zones when building a calendar). But still way less than 520.

Grouping of time zones is tricky, you don't want to group time zones solely based on their offset being the same, you have to consider the country and dst too. And on top of that ensure you're always up to date.

To solve that, I created a package and repository: https://github.com/vvo/tzdb

The package and data files are automatically updated whenever https://www.geonames.org/export/dump/ data changes.

My package has 317 time zones. The grouping of time zones is explained in the README, if you feel like the grouping is wrong, open an issue. Thanks!

@rns4731
Copy link

rns4731 commented Jul 20, 2020

+1 for a simplified list of 24 timezones

@jasonpau
Copy link

+1 for a simplified list of 24 timezones

-1 for a list that would not work in a surprisingly large number of cases. (A UTC offset definitely does not equal a timezone.)

If we managed to eliminate DST around the world, we'd be closer to only needing 24 timezones. There are other exceptions out there though that would still need special handling.

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

6 participants