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

Adding new grunt task data:timezones to create list of timezones, with an additional info: countryMap. #161

Closed
wants to merge 4 commits into from

Conversation

kashifshamaz21
Copy link
Contributor

Adding new grunt task data:timezones to create list of timezones, with an additional info: countryMap.
This should resolve the ticket raised at #158
Use-case:

  1. To group timezones based on countries, so that the timezone choices shown to end users has a two step selection menu:
    a) Select a country from list of countries (Menu 1)
    b) Populate the next menu with list of timezones used in the country selected in Menu 1
  2. Also, this grunt task builds the timezone list from zone1970.tab instead of the deprecated version zone.tab which the library currently uses.
    Ideally, we can just replace the grunt task data:meta with the one added in this commit data:timezones.
    The new task creates a timezones-list.json file which is using data frm zone1970.tab, and has additional property for each zone. So its not removing any of the properties that were being added by the data:meta task.

…ith an additional info: countryMap. This info can be used to group timezones based on countries.

Also, this will build the timezone list from `zone1970.tab` instead of the deprecated version `zone.tab` which the library currently uses.
@timrwood
Copy link
Member

This is looking good, thanks for your help with it!

I think we can just modify the data-meta task with these updates. I don't see the need for both versions.

I think we can also rearrange the data a bit so it is more optimal for the common use cases. What about something like this?

{
  countries: {
    US : {
      name: "United States",
      abbr: "US",
      zones: ["America/Los_Angeles", "America/New_York"]
    },
    FR : {
      name: "France",
      abbr: "FR",
      zones: ["Europe/Paris"]
    },
    ...
  },
  zones: {
    "America/Los_Angeles" : {
      name: "America/Los_Angeles",
      latitude: 34.0522,
      longitude: -117.7572,
      countries: ["US"],
      comments: "Pacific Time"
    },
    ...
  }
}

1. Pick "zone1970.tab" as its input source if available, defaults to zone.tab. (until 'tzdata2014f', only zone.tab was available, but now its the deprecated version)
2. Output JSON of this task now has two hashes: "countries" and "zones" to facilitate consumers to deal much better with showing timezone choices.
@kashifshamaz21
Copy link
Contributor Author

@timrwood Thanks for the quick review, and yes even i was thinking on silmilar lines for the json structure, but didn't want to add breaking changes if others were already consuming the metadata json.

But now i have gone ahead and modified the output JSON structure to have two hashes:
countries & zones.(same as you had suggested)

This set of commits should fix #158, #159, #160.
Please review and would be great if we can get this into some release soon.

Questions:

  1. The data/meta/2014*.json files were created using the older grunt task, so the json structure in those is different from the one created by this updated task.
    Do we need to re-build the meta data files for all those as well: 2014a, 2014b .. etc?

@timrwood
Copy link
Member

Looking good!

I rebased your commits down to one and made a couple edits. Instead of prefixing timezones-list- to the metadata files, they are back to latest.json and 2014g.json as before. There is a pull request at #162 to merge that into develop, so I'll close this one in favor of that one.

I think we'll have to do a minor version bump for this change and note the breaking changes in the changelog.

I'll rebuild the metadata files for all the releases this year and push to that other PR.

@timrwood timrwood closed this Dec 12, 2014
@kashifshamaz21
Copy link
Contributor Author

To consume the meta data, would require utility functions like:
a) moment.tz.zones()
b) moment.tz.countries() etc.
c) Query for zones in a specific country or set of countries..
I know we have an API moment.tz.names() which gives a list of zones, but it may not be of much use as it lists all possible zones, including those which are aliases(links).
It would make sense if these utils are also added to this library. Otherwise, same piece of logic would be duplicated by users of the metadata file, to fetch list of zones/countries, filter zones for a country etc.
Thoughts?

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.

2 participants