Comments (9)
There's now moment.tz.names()
moment.tz.names(); // ["Africa/Abidjan", "Africa/Accra", "Africa/Addis_Ababa", ...]
from moment-timezone.
The tz data is just an object with a couple of big arrays. You can get at the zones easily with momentTZData.zones
.
Regarding ordering "correctly" - I don't believe there is any particular sort order that is "correct" for IANA zone names. You could sort them alphabetically, or geographically, or by standard offset, or by current offset. Any would be acceptable.
If your intention is to produce a drop-down list for user selection of time zone, I would recommend you consider a map-based picker instead. They are much more user friendly. This one is my favorite but there are others out there.
from moment-timezone.
@mj1856 I couldn't get momentTZData
at all (except in the http://momentjs.com/timezone site).
Since there IS a need for getting the list of timzones, I don't see why not adding a getAll
kind of method.
from moment-timezone.
All the data is available in the moment-timezone.json file at the root of the repo.
I suppose we could expose a method that lists the names of all the installed zones and links in case someone wants to use the data builder to get a subset of all the data.
Something like this.
moment.tz.zones(); // ["Africa/Abidjan", "Africa/Accra", "Africa/Addis_Ababa"...]
from moment-timezone.
I think exposing a method to get the data would be great. It's already there, just a private method.
Completely unrelated to this issue, but it would be nice to have a version of the zone name suitable for display in a UI, such as a dropdown.
from moment-timezone.
@dawnerd - We only have what's provided by the TZDB. To get display names, we'd have to pull in language-specific CLDR data, which can be quite large.
There are quite a few projects that implement CLDR data in JavaScript. Here is one that appears to have time-zone specific translations separated out. You could use that data to build your dropdown. I have no idea how current that library is or if they stay on top of CLDR updates. There may be better ones somewhere.
@timrwood - Am I correct that you don't plan to pull CLDR localized translations of time zone display names into moment-timezone? Or is that something you want to consider to align with how moment localizations work?
from moment-timezone.
Yeah, this is probably best left out of moment-timezone
.
All the information needed to map a zone to a display name is available, and duplicating the efforts of CLDR from within this library doesn't really make sense.
from moment-timezone.
@brewhk-dev is this change checked into the latest release?
moment.tz.names()
from moment-timezone.
@aaronmagi A quick check on the changelog.md tells me it was added in version 0.1.0
on 23rd June, 2014
from moment-timezone.
Related Issues (20)
- The DST calculation does not take effect. HOT 3
- import moment from 'moment-timezone'; import 'moment/min/locales'; not working HOT 5
- Can not set default timezone HOT 2
- Wrong timezone conversion
- error TS2350: Only a void function can be called with the 'new' keyword. new moment(); HOT 3
- 2023d is out HOT 2
- Some tz.guess() tests are failing in 2024 HOT 1
- Canada/Yukon offset before 1967 May 27 is wrong HOT 1
- How does moment.tz(unixTimestamp,timezone) and moment.tz.guess() work? HOT 1
- How can I use moment-timezone with 10 year data range with Typescript types HOT 1
- Moment Timezone has no data for Europe/Ljubljana
- Kazakhstan will switch to a single time zone, UTC+05:00, on March 1, 2024. HOT 1
- 2024a released HOT 1
- Test failure due to rounding error HOT 2
- Timezone Error in v0.5.45 HOT 1
- Wrong Kazakhstan Timezone in 0.5.45 HOT 1
- Incorrect Timezone Offset for 'Asia/Almaty' HOT 1
- The moment-timezone get the time zone of Kazakhstan Asia/Almaty in January 2024 to the DST. HOT 1
- Is there an alternative to moment-timezone with bundled IANA TZ DB?
- Getting spilt issue while using moment and moment-timezones HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moment-timezone.