- cross-posted to:
- programmer_humor@programming.dev
- programming@programming.dev
- cross-posted to:
- programmer_humor@programming.dev
- programming@programming.dev
cross-posted from: https://programming.dev/post/33754840
new Date(“wtf”)
Until the new Temporal API comes along, there are some libraries we can use.
- luxon
- dayjs
- or compile chrono (Rust) to WebAssembly
Luckily the new Temporal API is shaping up.
I quite like this one.
Ok, I get that the Date API is problematic, but I wouldn’t expect anything meaningfull from
new Date("not a date").getTime()anyway. Why would you in the first place?In the process of being replaced.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal
JavaScript has had the
Dateobject for handling date and time since its first days. However, theDateAPI is based on the poorly designedjava.util.Dateclass from Java, which was replaced in the early 2010s; but, because of JavaScript’s goal of backward compatibility,Datesticks around in the language.Hmm, I can believe that it was based on
java.util.Date, but I don’t remember that being as unpredictable. I guess, a different API to begin with, would have avoided a lot of problems, though…Damn, I thought you meant JavaScript itself was being replaced.
One can only
undefined





