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

Added new APIs - tz.countries(), tz.country(), tz.zonesOfCountry to consume meta data about timezones. #175

Closed

Conversation

kashifshamaz21
Copy link
Contributor

Its a large commit, with plenty of additions so please bare with me! :)
Summary
The goal here is to add a new set of APIs to the toolkit of moment-timezone to consume meta-data about countries. following is the list of new APIs:

  1. moment.tz.countries(): Returns a list(array) of Country objects.
    Each Country object has:
{  name : "India",
   abbr   : "IN",
   zones : ["Asia/Kolkata"]
}
  1. moment.tz.country(countryCode): Returns the country object for the given ISO 3166 alpha-2 country code
  2. moment.tz.zonesOfCountry(countryCode): Returns a list(array) of zone objects used in the country. For this API, a few additional properties are added to the Zone objects:
{  name: "America/Los_Angeles",
   abbrs: [...],
   offsets: [...],
   untils: [...],
   currentAbbr: "PST",  // the current abbr in effect in this zone
   currentOffset: "480",  // the current offset from GMT(minutes) in effect in this zone
   currentAbbr: "-0800",  // the current offset string in effect in this zone
}

Tests: New test cases for these additional APIs/utils have been added in following locations:

  1. tests/moment-timezone/countries.js: Tests the three APIs mentioned above.
  2. tests/moment-timezone/pack-country.js: Tests the utils which packs the country data.
  3. tests/moment-timezone/unpack-country.js: Tests the utils which unpacks the country data.

Docs: The docs have been updated to reflect the change in the order in which the grunt tasks are run, namely, have moved data-meta task to happen before data-pack.

@timrwood Its a huge commit, lots of changes, so please take your time in reviewing it! The core tests have all passed, so it looks fine from that point of view, but would definitely like an additional pair of eyes to run through this patch.
Thanks.

@kashifshamaz21
Copy link
Contributor Author

Some assertions failing for a couple of African timezones, but not sure why, because my changes shouldn't have affected them in anyway. @timrwood Can you have a look at them?

….awk" file, which got added from verion 2014g onwards.
@acorbi
Copy link

acorbi commented Feb 11, 2016

@kashifshamaz21 can you shed some light on the context and status of this PR? at https://sharethemeal.org we rely on moment-timezone library intesively and would love to see this features be integrated in the API. I would even think about collaborating in order to complete your PR if you could walk me through the pending tasks

@adgrace
Copy link

adgrace commented Sep 1, 2016

Hi, I have only just seen this PR! I have just submitted a PR for similar functionality as requested in issue 289.

It is passing all checks, please see what you think:
#377

If there is anything to improve or any more functionality to add please let me know 👍

@adgrace
Copy link

adgrace commented Nov 1, 2016

Pull Request has been submitted and is passing all checks:
#410

Appreciate any feedback!

@maggiepint
Copy link
Member

close stale

@maggiepint maggiepint closed this Aug 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants