Live data from Hacker News

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

github.com

11–20 of 80 posts

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

#11

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

After minification with Uglify:

27.3 KB compressed with `gzip -9`, 26.4KB with `zopfli -i1000` and 24.0KB with `brotli -q 11`.

(kilo, not kibi)

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

#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.

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

#15

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.

I think that moment.js was already built that way. For me it kinda makes sense: if days are calculated with a 1-index in mind, why make months different? As I said: it KINDA makes sense.

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

#16
post #4

Earlier quoted context omitted.

Thanks. This link should be on the github page to be honest. For people like me who do not (always) click through if they don’t see an immediate need. Only now notice the url contains moment and this is part of moment.

Well, perhaps the people who don't care to investigate just aren't a target of this library at the moment.

"at the moment"? No pun intended?

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

#17
post #11

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

After minification with Uglify: 27.3 KB compressed with `gzip -9`, 26.4KB with `zopfli -i1000` and 24.0KB with `brotli -q 11`. (kilo, not kibi)

TIL they just completely redefined a kilobyte a while ago.

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

#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

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

#19

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.

OTOH, as somebody who doesn't do much date stuff JS/moment's months are a constant source of bugs.

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

#20
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.

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?

Post reply on HN