Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by usefulcat on Wednesday March 11, 2026 @08:39PM
(#47344694)
[ Parent
| on HN ]
Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by hdjrudni on Thursday March 12, 2026 @12:34AM
(#47346481)
Sorry, sleep returned a Promise and you didn't await it. You called foo() immediately.
Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by koakuma-chan on Thursday March 12, 2026 @01:53AM
(#47347009)
What you want there is to stop saying "day" and instead say "24 hours." This way the code is correct and you don't need to deal with time weirdness.
Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by danbruc on Thursday March 12, 2026 @05:10AM
(#47348218)
No, because if I want something to happen everyday at 12 o'clock, I have to wait for one day, if I wait for 24 hours, I will be off by an hour for half of the year.
Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by loloquwowndueo on Thursday March 12, 2026 @06:37AM
(#47348808)
Only if you live in one of the brain dead countries that observe the dst anachronism.
Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by eureka7 on Thursday March 12, 2026 @09:32AM
(#47350308)
ok, but they still observe it and you still have to deal with it in your code.
our personal convictions don't change that fact.
Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by koakuma-chan on Thursday March 12, 2026 @10:24AM
(#47350953)
Why do you want something to happen everyday at 12 o'clock specifically? If this is truly what you want, sure.
Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by danbruc on Thursday March 12, 2026 @05:14PM
(#47357221)
Lunch break reminder popup?
Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by mklepaczewski on Thursday March 12, 2026 @06:08AM
(#47348572)
You seem to assume that a day always has 24 hours. Common (but not only) non-24h day lengths are:
- 23 hours
- 25 hours
- 24 hours 1 second
- 23 hours 59 minutes 59 seconds
You could assume that a day isn't exactly 24 hours, but it's close-ish to 24 hours. Nope, not even close.
And that assumes that we can treat an hour as a precise measure of time (we can't). On some systems, even a second is not a precise measure of time (second smearing).
To make things worse, those are "simple" edge cases.
Time is hard. I'm not sure if I can make any statement about time that is true.
Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by koakuma-chan on Thursday March 12, 2026 @10:35AM
(#47351125)
I am saying that you shouldn't use day as a unit of time. You should use second, minute, hour, etc, because these have a constant duration. sleep(86400) should reliably make your thread sleep for at least 24 hours.
Re:Temporal: The 9-Year Journey to Fix Time in JavaScript
by mklepaczewski on Thursday March 12, 2026 @12:11PM
(#47353002)
It depends on the context and the system you’re working with. In some systems, an hour may last 3599, 3600 or 3601 seconds (due to the leap second), a minute may be 59,60 or 61 seconds. Even a second is not always a „true” second.
There’s no single time unit that works for all situations.