getting updated timezone information in nodejs and types of libraries involved

194 Views Asked by At

With regard to my previous question on how to manage timezone specific date as well as manage their conversions, I have been trying to think of a way to be able to get updated timezone information that reflects the latest possible data of the iana tz db.

Since I'm using nodejs, my options was to use a library that dealt with timezones.
I found the following type of libraries, and I have queries related to each one:

  1. That use the Intl api, and maintain/package no timezone information themselves(libraries include date-fns-tz, day.js):

    • First page of date-fns-tz says:

      Time zone support for date-fns v2.0.0 using the Intl API. By using the browser API no time zone data needs to be included in code bundles. Modern browsers and Node.js all support the necessary features, and for those that don't a

    • As far as I can see, they dependent on nodejs itself managing the timezone data, which in turn depends on the ICU library, which doesn't seem to be updated quite often even though nodejs version itself gets updated. Question a., is this a correct deduction, or do they query some external servers(user's system/remote etc)?
  2. Libraries that rollout their own compilation of tzdb (moment-timezone):
    They seem to update quite periodically, but, in the particular case of moment-timezone, it seems to be an addon for moment, but, they both seem to be legacy project, and the homepage itself suggests not using it.

The best option for me would be the option number 2. But, as you can see above, I'd like to avoid using a legacy project. So, my Question b. would be for a suggestion for a method to get the most updated timezone information for use in nodejs(possibly another library suggestion or something else)

1

There are 1 best solutions below

3
On

So, my Question b. would be for a suggestion for a method to get the most updated timezone information for use in nodejs(possibly another library suggestion or something else)

I personally used moment for years but when it was classified as a legacy project, I switched to dayjs with the timezone plugin. Hope it helps

Day.js supports time zone via the Internationalization API in supported environments. By using the native API, no extra bytes of timezone data need to be included in code bundle. The list of all time zone names can be fount in the IANA database.