Search code examples
javascriptnode.jstimezonemomentjsmoment-timezone

How does momentjs keep timezone data up to date


As timezone data can change, especially daylight saving time rules, how does momentjs keep up to date with this information?

If I'm using momentjs-timezone for a scheduling system that is timezone dependent, do I need to do any maintenance to keep the timezone data up to date? If momentjs automatically manages this, how does it do that?


Solution

  • From the moment-timezone docs:

    The data for Moment Timezone comes from the IANA Time Zone Database. New versions are released periodically as time zone laws change in various countries.

    The versions are named after the year and an incrementing letter. 2014a 2014b 2014c...

    In order to keep versions together, Moment Timezone has a bundled object format as well.

    You can access both the moment.tz version and data version:

    const moment = require("moment-timezone");
    console.log(`moment.version: ${moment.tz.version}`);
    console.log(`moment.dataVersion: ${moment.tz.dataVersion}`);
    

    This will look like:

    moment.version: 0.5.33

    moment.dataVersion: 2021a

    You can see from the dataVersion how up to date the timezone data is and whether it needs updating.

    You will need to update your installed version using npm / yarn to get any timezone changes.