News for hackers. Stuff that matters.
Re:Dates and Times in JavaScript – A New API for Dates from ... by kcorbitt on Thursday July 09, 2020 @01:51PM (#23782930)
https://date-fns.org/ is the most popular alternative to moment-js, has an intuitive functional API and treats dates as immutable. I migrate every project I touch over to it since it has so many fewer footguns.
Re:Dates and Times in JavaScript – A New API for Dates from ... by pyrhho on Friday July 10, 2020 @07:26AM (#23790391)
I wanted to use date-fns on the current project. But, the gotcha is due to its lack of timezone support many of its functions are inherently broken (e.g. startOfWeek). So, if you need rich calculations with timezone support watch out!
Re:Dates and Times in JavaScript – A New API for Dates from ... by erichurkman on Thursday July 09, 2020 @05:11PM (#23785278)
+1 for date-fns. It's not uncommon to look at a downloads in a JavaScript bundle to find out Moment — and its timezone and localization files — are a huge percentage of a download for a single `moment.format()` call.
Re:Dates and Times in JavaScript – A New API for Dates from ... by eropple on Thursday July 09, 2020 @02:47PM (#23783609)
Huh - thanks for the link. The Moment folks also have Luxon, which I've been using, but there's quite a lot more momentum behind date-fns.
Re:Dates and Times in JavaScript – A New API for Dates from ... by Drdrdrq on Thursday July 09, 2020 @04:34PM (#23784841)
Or give day.js a try. It is basically moment.js without its problems, and pretty popular too. I tried date-fns but found it cumbersome to use... Ymmv.