Skip to content

Instantly share code, notes, and snippets.

@timrwood
Created May 31, 2014 01:26
Show Gist options
  • Save timrwood/fc6e091c39a0ef8d9911 to your computer and use it in GitHub Desktop.
Save timrwood/fc6e091c39a0ef8d9911 to your computer and use it in GitHub Desktop.
Moment Timezone Data Update Process

1. Download from iana.org/time-zones

temp/download/northamerica
temp/download/africa
temp/download/...

2. Compile with zic(8)

temp/zic/america/los_angeles
temp/zic/america/new_york
temp/zic/america/...

3. Dump with zdump(8)

temp/zdump/america/los_angeles
temp/zdump/america/new_york
temp/zdump/america/...

4. Collect with a grunt task

// data/zdump/2014a.json
[
  {
    name    : "America/Los_Angeles",
    abbrs   : ["PST", "PDT", "PST", "PDT", "PST", "PDT", "PST", "PDT", "PST", "PDT"],
    offsets : [420, 480, 420, 480, 420, 480, 420, 480, 420, 480, 420, 480, 420, 480],
    untils  : [-134089073429, -134074893883, -13407683724, -134074372626, -134074937463, -134074937463]
  },
  {
    name    : "America/San_Francisco",
    abbrs   : ["PST", "PDT", "PST", "PDT", "PST", "PDT", "PST", "PDT", "PST", "PDT"],
    offsets : [420, 480, 420, 480, 420, 480, 420, 480, 420, 480, 420, 480, 420, 480],
    untils  : [-134089073429, -134074893883, -13407683724, -134074372626, -134074937463, -134074937463]
  },
  ...
]

5. Dedupe zdump data with a grunt task.

Loop through all zones, and remove entries that have the same abbr and offset as the next entry.

data/unpacked/2014a.json

6. Pack data from the unpacked dir with moment.tz.pack.

data/packed/2014a.json

7. Generate tests from the zdump data.

tests/zones/america/los_angeles.js
tests/zones/america/new_york.js
tests/zones/...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment