Live data from Hacker News

Luxon – A library for working with dates and times in JS

github.com

21–30 of 80 posts

Re: Luxon – A library for working with dates and times in JS

#21
post #13
post #7

PLEASE use joda-js on Javascript: https://js-joda.github.io/js-joda/ It's a port of the java8 date/time API, which is the most correct date-handling library there is.

What if one does not want to use a port of Joda? Even looking at the documentation makes me run away. Where are all the examples? date-fns seems good, moment works well too, despite its flaws, this new one is worth looking at. Dismissing all other libraries isn't very helpful. And yes, I realise all other libraries are wrappers around Date. It works well enough for 99% of cases.

Agree with your points, but I really thought joda-time’s documentation was decent! Cheatsheet had plenty of examples: https://js-joda.github.io/js-joda/cheat-sheet.html

Re: Luxon – A library for working with dates and times in JS

#22
post #21
post #13

Earlier quoted context omitted.

What if one does not want to use a port of Joda? Even looking at the documentation makes me run away. Where are all the examples? date-fns seems good, moment works well too, despite its flaws, this new one is worth looking at. Dismissing all other libraries isn't very helpful. And yes, I realise all other libraries are wrappers around Date. It works well enough for 99% of cases.

Agree with your points, but I really thought joda-time’s documentation was decent! Cheatsheet had plenty of examples: https://js-joda.github.io/js-joda/cheat-sheet.html

Thanks. I didn't find that last time. Examples should really be in the actual documentation.

Re: Luxon – A library for working with dates and times in JS

#23
post #5

How does it compare to date-fns?

Biggest remaining difference I can see is that Luxon still has it's own classes while date-fns operates on bare DateTime objects (AFAIK), which allows for a different kind of API. So it's mostly a matter of personal preferences now.

Re: Luxon – A library for working with dates and times in JS

#24

Months in Luxon are 1-indexed instead of 0-indexed like in Moment and the native Date type. This seems like a bold decision and terrifying source of errors for those of us with decades of experience thinking January is 0.

ISO 8601 say January is 01

Re: Luxon – A library for working with dates and times in JS

#25

I've migrated a lot of code from moment to date-fns because of moment's bulky size and vast, mutable API. Luxon seems to fix the API issue. date-fns is still great for simple operations, but I'll definitely consider this for new projects with nontrivial datetime handling.

Yes, mutation in Moment has burned me a few times before I realized that occurs.

Edit: wow, I just looked at the repo and realized its made by the Moment team. That might be pretty cool.

Re: Luxon – A library for working with dates and times in JS

#26
Sorry for the dumb questions, I haven't worked with js much, but what does this add to the standard library?

Going just by the one example there, I can see that timezone by location is probably extra, that's perfectly fine. The endOf modifier seems more like a helper to fix broken date/time model in js? But other parts should probably be in the standard library? I was under the impression js is improving fast nowadays, will stuff like this get into the language?

Re: Luxon – A library for working with dates and times in JS

#27
post #20
post #13

Earlier quoted context omitted.

What if one does not want to use a port of Joda? Even looking at the documentation makes me run away. Where are all the examples? date-fns seems good, moment works well too, despite its flaws, this new one is worth looking at. Dismissing all other libraries isn't very helpful. And yes, I realise all other libraries are wrappers around Date. It works well enough for 99% of cases.

https://js-joda.github.io/js-joda/cheat-sheet.html EDIT: My precious internet points! ;) - wait, is this not a page of examples, as linked to from the GitHub page?

I think you might be downvoted because you plastered a link with no explanation. It doesn't actually address my concern, which was that when I was reading the documentation I did not see any examples.

Re: Luxon – A library for working with dates and times in JS

#28
post #26

Sorry for the dumb questions, I haven't worked with js much, but what does this add to the standard library? Going just by the one example there, I can see that timezone by location is probably extra, that's perfectly fine. The endOf modifier seems more like a helper to fix broken date/time model in js? But other parts should probably be in the standard library? I was under the impression js is improving fast nowaday…

From what I've seen JavaScript's standard library doesn't change much, most the changes are language changes?

As for what it adds, looks like duration and interval classes.

Re: Luxon – A library for working with dates and times in JS

#30
post #18

How does this compare in file size to Moment? That's the only real issue I have with it.

If you only want timezone conversions I removed everything else from Moment. It's less than 2KB uncompressed: https://github.com/scorredoira/timezone.js

I my experience the actual timezone information is the heaviest portion of the payload. I can't wait until all browsers have support for `Intl`
Post reply on HN