-
Notifications
You must be signed in to change notification settings - Fork 838
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
I don't see a way to get an easy list of the available timezones #43
Comments
Hi. A few things:
So when you take all of this into consideration, the best we could do would be to spit out an array of all of the time zone names that we know about, such as |
Thank you for the response and the clarifications, my example was just a rough sketch of what was desired, pardon my misconceptions. I appreciate the work done on this library, this request should really just be considered an "enhancement" request, since it is not regarding anything wrong with moment-timezone. I do believe that even something as simple as "an array of all of the time zone names that we know about, such as Regarding the offset being invalid, what about an "offset" and "offsetDST", returning, say, -5 and -4 respectively? Regarding the descriptions such as "Eastern Standard Time", plugging "Москва, стандартное время" into Google translate outputs "Moscow Standard Time", so it appears to simply be a 1:1 translation. Perhaps the library can simply return the English description and that can be handled by however an application chooses to do localization? Lastly, regarding any of the data that would need a "point in time" for referencing, maybe it could be an optional parameter like My use case for this was simply wanting to populate a select field on a web app with a list of selectable timezones for the user. Right now I have to make my own data structure, which is not a huge deal but if I add a new timezone to the |
Rather than using your own data structure, you could just iterate through the data in the Have you considered instead using a map-based timezone picker? They tend to work much better with end-users than drop-down lists. Take a look at this one or this one. |
As previously suggested, it sounds like you need CLDR. A colleague of mine has written a handy module for getting that data out: https://github.com/papandreou/node-cldr (AFAIK, we generate the required client-side source-code from CLDR using this module; that way we only send the data we actually need...) |
@msiebuhr Thanks for the link! I haven't had the time to investigate CLDR for JS libraries yet, but I will take a further look at that one. Can you elaborate on that second part? Are you using this in the browser? |
We have a build-system (https://github.com/One-com/assetgraph; like these Grunt-build thingies, except it actually understands HTML, CSS, JS, ... and applies all sorts of optimizations on it) where we generate all (or: as much as we can) data like this up front. AFAIK, we don't touch CLDR once inside the browser. |
This issue raises an interesting challenge: Building any app that is designed to be globally available but locally consumed will have to account for UTC to local conversion. @mj1856 I agree that Visual Maps can be a good way of selecting, but I'm trying to focus on building an experience that always degrades to mobile well. Neither of those two do, while a good old dropdown list with a word-wheel does. You mentioned |
var zones = _.keys(momentTZData.zones) |
I couldn't figure out how to retrieve the global
|
I could not find any usage of I also did a quick search and don't see any mention of |
Here's what I do.
|
This has been added in http://momentjs.com/timezone/docs/#/data-loading/getting-zone-names/ |
Using moment.tz.names() returns a list of over 500 elements, is it possible to condense that down so that there is just one for each zone? If this were to be used to populate a drop down to allow a user to select their timezone, then it would be completely impractical |
@elewin see #227. But also, listing out the IANA identifiers isn't so great anyway. One needs CLDR data to do it right. There's certainly room for a javascript-only version of something like my demo here. Oh, and please don't make a habit of commenting on years-old-closed issues. ;) |
@markuso - ERROR TypeError: moment.tz.zones is not a function, which version of momentjs you are using? |
@markuso - i am getting list either 592 or 365 (if i filter out) entries for moment.tz.names(). Is there any way to use standard timezones, smaller list? |
@markuso - please let me know if there is any way to filter the list to get less than 50 timezones? |
@psagar5 I am not aware of any smaller list or a specific way to filter the list to some sort of standard short list. To cover worldwide time zones, you need the full list. In our application, we just show the full list to our users grouped by the first section of each name. Like "America" heading for all the "America/***" zones, etc. Sorry, maybe someone else could have a better answer about a standard short list you speak of. |
What we ended up doing was mapping the IANA time zones to Windows time zones, then we let the user select a windows time zone to narrow things down, then drill down further and list all the IANA time zones that fall under it so they can select the IANA time zone that applies specifically to them. It is much easier to quickly narrow down the time zones you present to the user that way. |
@elewin - can you share code snippet of your implementation? |
@psagar5 Sure,
Then, on the UI we have a drop-down that shows the I don't remember where we got that map of time zones from though; I can't recall if its something that we compiled our self or if it's from some other open source project; if its from another open source project then apologies to whoever wrote it, at the moment I can't find the original link where its from to give proper credit :( |
@elewin Maybe this one: |
Hi, is there a way to get the list of common timezones alone, just as pytz.common_timezones(basically just sends a list of timezones which are commonly used other than UTC as well as maintains the non deprecated list)? This is something I have looked for sometime but had no luck. Any ideas? |
My use case is populating a select element with options for the available timezones so the user can set their timezone. I was hoping for something along the lines of
moment.tz.getTimezones()
which would return something like
The text was updated successfully, but these errors were encountered: