4 ms·
Am I the only one who feels like Date is actually a decent API, quite easy to use and good enough for almost everything I’ve ever needed? Temporal seems needles
by sholladay 2y ago
Am I the only one who feels like Date is actually a decent API, quite easy to use and good enough for almost everything I’ve ever needed? Temporal seems needlessly complex and not something I want to use.
Sure, Date could be better. I wish Dates were immutable. I wish UTC was the “default” instead of having to call all the UTC methods. And sure, formatting via toLocaleString() isn’t the most intuitive way to do things. But… it works and it’s pretty straightforward.
If I need time only without the date, there’s a method for that. If I want ISO 8601, there’s a method for that and it’s even the default when the Date is sent in JSON. If I want a UNIX timestamp, there’s a method for that and it’s even the default when the Date is used as a number, which also makes Dates easily comparable and sortable. The `Intl` API has a lot of ways to format Dates.
IMO Dates are underrated. Though they could benefit from a more ergonomic formatting method, a la `moment, maybe a more flexible parser, and some support for leap seconds.