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

Replace moment dependency with a modern library #55

Open
stefanvanherwijnen opened this issue Aug 15, 2023 · 3 comments
Open

Replace moment dependency with a modern library #55

stefanvanherwijnen opened this issue Aug 15, 2023 · 3 comments

Comments

@stefanvanherwijnen
Copy link
Contributor

Moment is now considered a legacy project:
https://www.npmjs.com/package/moment

There have been multiple PR's already:
#53
#48
#2

It would be nice if @commenthol could clarify which newer library should best be used.

@commenthol
Copy link
Owner

In reality this project relies heavily on moment-timezone. The important data here is the reliability on the timezone which uses data from IANA time zone database that is maintained and up to date.

Unfortunately moment-js is required for using moment-timezone.

I understand the current moment project status and the need to move to some other library instead.

Nonetheless I fear that this will cause major drawbacks with the accuracy. The IANA Database is usually maintained by the underlying OS. In case of nodeJS the timezone database seams to be queried by the included ICU library.

From https://stackoverflow.com/questions/55477931/where-does-node-js-get-the-timezone-data-from

Generally, it should be noted ICU data archive is updated less frequently than the IANA timezone data. Therefore, you may have to deal with outdated timezone information in Node.js even if you always install the latest Node.js LTS release. This is indicated by the tz properties value 2018e which indicates a fairly old version of timezone data. The current IANA timezone data is dated from March 2019

IMO Luxon or date-fns will suffer from this design decision.

If used in the browser, things tend to be worse.

From https://support.google.com/chrome/thread/139901584/does-chrome-use-iana-database-for-timezone-information?hl=en

Chrome on Windows uses the date and time settings built-in to Windows.

With moment-timezone it can be accomplished that the timezone-data is accurate amongst all clients and platforms. This is something I don't want to trade with tickets stating that this and that date is wrong, but in reality timezone data on that client is outdated.

I am following the Temporal.ZonedDateTime Proposal which I would consider as a replacement for moment-timezone. But again we'd need to see where to get really up to date timezone data amongst all clients using this library.

Maybe you are aware of a JS-project which uses IANA timezone data and offers this in a "tiny" library.

@stefanvanherwijnen
Copy link
Contributor Author

Thanks for your thorough explanation. This should clear things up for everyone (including me) wondering why we are stuck with moment.

Unfortunately I am not aware of any alternatives myself. date-holidays works great, but I am getting errors when using it in the browser due to moment not supporting ESM. And since moment won't be updated, the best solution seems to be to find a suitable replacement for it.

@Willham12
Copy link

seems like date-fns is the best pick.

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

No branches or pull requests

3 participants