I am using Day.js
to handle timezone related operations. Day.js
relies on the JavaScript Internationalization API (Intl) to get timezone data.
To my understanding, the Internationalization API relies on the underlying system/browser to provide timezone information.
My question is, how would I check if the timezone data used by the Internationalization API has been updated?
Why do I care about this?
I store future dateTimes
with 3 values:
dateTime
(local to the associated timezone)dateTime
When there is a change in this timezone data, it might happen that the offset between the "local" and "utc" dateTimes
is no longer correct. When this happens I would like to know about it, so that I can calculate and store the new utc dateTime
, such that the offset is now correct.
I found the answer for Node.js
environments (not sure about browser environments though).
In Node.js
you can find a list of all of the versions of its dependencies on process.versions
(docs). One of these is the tz
dependency, which corresponds to the version of the timezone data used (the IANA version).
In order to check if the version has changed, I store the version in the db and simply compare.