News for hackers. Stuff that matters.
Re:It’s OK for your open source library to be a bit shitty (... by redis_mlc on Sunday May 17, 2020 @05:55AM (#23210899)
> I'm not into js at all

Programming in JS is just this way.

I had to include moment.js yesterday just to format a date. Nothing fancy, but no easy way around it.

Re:It’s OK for your open source library to be a bit shitty (... by smichel17 on Sunday May 17, 2020 @06:26AM (#23211008)
I'm not sure this is a good example; dates are actually pretty complicated.
Re:It’s OK for your open source library to be a bit shitty (... by HereBeBeasties on Sunday May 17, 2020 @02:16PM (#23213935)
Yes, dates are very complicated. But that doesn't stop pretty much every modern language from having good built-in support for doing this, because it's such a totally common task. JavaScript is such a mess. It doesn't even support integers, for crying out loud, let alone decent date/time/timezone handling. That moment.js is the most popular band-aid to fix this, despite it having a nasty gotcha API that mixes mutable and immutable functions/types in confusing ways just rubs salt into the wound. Heck, you can't even compare two moment dates with inequality operators without either casting them by prepending a plus sign, or calling functions - it just silently does the wrong thing.
Re:It’s OK for your open source library to be a bit shitty (... by ZeikJT on Sunday May 17, 2020 @07:19PM (#23216448)
Silently? Since when is comparing objects in JS with (in)equality operators the right thing to do? There's no operator overloading nor special symbol you can implement in objects to make this work seamlessly ever. Casting/stringifying or calling functions is the only way for all objects.
Re:It’s OK for your open source library to be a bit shitty (... by orange8 on Monday May 18, 2020 @09:43PM (#23230480)
Re:It’s OK for your open source library to be a bit shitty (... by orange8 on Monday May 18, 2020 @02:58AM (#23219196)
You did not have to, moment.js is just a wrapper around the dozens of inbuilt functions provided by the Date object.

Why could you not have used Date.toLocaleDateString() or Date.toDateString() or Date.toISOSting() or any other of the inbuilt functions outlined here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...