Passing Moment, Or Moment.js Replacement
At some point while dealing with date/time in JS code and searching for some clues, I stumbled over an advice "just use Moment" - and at that time, it was quite revelatory - I wasn't much used to the npm "package for everything" attitude, and haven't really thought that so many problems could have been solved by just using the right library.
And Moment.js stuck with me ever since - not that I needed day/time parsing or manipulation every day, but when I did need it, the answer was clear - just use Moment!
So it was quite a surprise to me that it's being deprecated - in fact, has been for quite some time already. The obvious questions were "why?" and "what now?".
Apparently Model.js has aged and doesn't do as good a job as it did before - as the maintainers say at the https://momentjs.com/docs/#/-project-status/future/,
Some of the problems one could fin on the Web is slowness, large size, mutability and debugging problems. For instance, there's a good comparison of the Moment against other libraries (and native solution) at https://inventi.studio/en/blog/why-you-shouldnt-use-moment-js - it's actually from pre-deprecation times, but I'd expect it still holds true:
There's a "recommendations" section on the Moment's website itself: https://momentjs.com/docs/#/-project-status/recommendations/, which list several alternatives, such as:
It's almost too much choice, but luckily that pre-deprecation article I've mentioned earlier has als a comparison of these alternatives considering certain functionality and size:
Which (among some suggestions elsewhere) points out that for general cases, Day.js or date-fns are probably the best choice, while for tricky cases and error-prone data Luxon might be a better choice.