Top
Best
New

Posted by robpalmer 5 hours ago

Temporal: A nine-year journey to fix time in JavaScript(bloomberg.github.io)
329 points | 120 commentspage 2
wpollock 3 hours ago|
> "It was a straight port by Ken Smith (the only code in "Mocha" I didn't write) of Java's Date code from Java to C."

This is funny to me; Java's util.Date was almost certainly a port of C's time.h API!

tracker1 2 hours ago||
Looking at the caniuse results... f*king Safari (and Opera)...

https://caniuse.com/temporal

beezlewax 1 hour ago||
And I have to support safari while dealing with all the problems that are mentioned in this article. Maybe there is a polyfill.
agos 2 hours ago||
I usually am not too harsh on Safari on implementation of new features but this is a bummer, and reflects poorly on them
kemayo 3 hours ago||
> Developers would often write helper functions that accidently mutated the original Date object in place when they intended to return a new one

It's weird that they picked example code that is extremely non-accidentally doing this.

SoftTalker 3 hours ago||
It's been a while since I worked in JS but dealing with dates/times, and the lack of real integer types were always two things that frustrated me.
philipallstar 4 hours ago||
> have to agree on what "now" means, even when governments change DST rules with very little notice.

I didn't spot how Temporal fixes this. What happens when "now" changes? Does the library get updated and pushed out rapidly via browsers?

apaprocki 14 minutes ago||
Depending on the situation, the data lives either within the browser or within the OS. Chrome releases ship versions of tzdata that correspond to the version of tzdata shipped with the ICU it uses, and they do backport updates to prior Chrome releases within a certain window. Apple has a sideband way of deploying tzdata to all devices that doesn't appear via the normal Software Update mechanism. So it all depends on which particular OS/browser combo you're interested in and the decisions those owners made.
WorldMaker 2 hours ago|||
Right, browsers own it instead of websites needing to rebuild Moment.js bundles. Additionally, most browsers pass the ownership further to the user's OS as the IANA timezone database is a useful system-level service and best updated at the cadence of OS "required" updates.
nekevss 4 hours ago||
Typically time zone data is updated in IANA's time zone database. That data would need to be updated in the implementation. In this case, the browser would need to update their time zone data.
hungryhobbit 4 hours ago||
From the article:

    const now = new Date();
The Temporal equivalent is:

    const now = Temporal.Now.zonedDateTimeISO();
Dear god, that's so much uglier!

I mean, I guess it's two steps forward and one step back ... but couldn't they have come up with something that was just two steps forward, and none back ... instead of making us write this nightmare all over the place?

Why not?

    const now = DateTime();
sheept 14 minutes ago||
I think that it's nice it's explicit that the method returns the current instant, rather than some other zero value.

There's also other methods that return other types, like

    const now = Temporal.Now.instant()
which isn't as bad.

One could argue that the ugliness of the API intentionally reveals the ugliness of datetime. It forces you to really think about what you mean when you want "the current date time," which I think is one of the goals of the API.

evolve2k 1 hour ago|||
Firstly, I really want this also and am supportive of an opinionated decision to put something at say Temporal.DateTime() that would be logical for developers to use ‘most of the time’.

However my guess is that the spec designers saw this lack of specivity as part of the problem.

A key issue of dates and times is that we use them culturally in day to day use in very imprecise ways and much is inferred from the context of use.

The concepts of zoned time and “wall clock” time are irreducable and it’s likely much code will be improved by forcing the developer to be explicit with the form of time they want to use and need for their particular use case.

I think this is why it’s so explicitly specified right now.

But I agree; I’ve often struggled with how verbose js can be.

Maybe with time (pun intended), more syntactic sugar and shorter conventions can be added to expand what has been an incredible effort to fix deep rooted issues.

sourcegrift 3 hours ago||
If you give me your background I'll explain in longer terms but in short it's about making the intent clear and anyone who understands s modicum of PL theory understands why what's a constant is so and what's a function is so.
Bratmon 2 hours ago|||
I'm excited for this conversation. If you see someone respond to a developer ergonomics complaint with "If you give me your background I'll explain in longer terms... anyone who understands s modicum of PL theory" you're about to see some legendary bullshit.

It's like witnessing a meteor shower!

themafia 2 hours ago|||
I'm a programmer. I'm a human. Perhaps we should also allow for some "human theory" inside our understanding.
redbell 4 hours ago||
Oh, for a second, TeMPOraL (https://news.ycombinator.com/user?id=TeMPOraL) came to my mind!
samwho 5 hours ago||
Thanks for linking to my silly little quiz in the article! :)
ventuss_ovo 2 hours ago||
interesting point about immutability
sharktheone 5 hours ago|
Very happy for it finally being there!
More comments...