←back to thread

setBigTimeout

(evanhahn.com)
210 points cfj | 1 comments | | HN request time: 0.41s | source
Show context
yifanl ◴[] No.41880869[source]
If we're pedantic, this doesn't actually do what's advertised, this would be waiting X timeouts worth of event cycles rather than just the one for a true Big timeout, assuming the precision matters when you're stalling a function for 40 days.
replies(3): >>41880887 #>>41882515 #>>41890330 #
ballenf ◴[] No.41882515[source]
Each subtracted timeout is a 25 day timer, so any accumulated error would be miniscule. In your example there would a total of 2 setTimeouts called, one 25 day timer and one 15 day. I think the room for error with this approach is smaller and much simpler than calculating the date delta and trying to take into account daylight savings, leap days, etc. (but I don't know what setTimeout does with those either).

Or maybe I'm missing your point.

replies(1): >>41885374 #
1. zeroonetwothree ◴[] No.41885374[source]
You don’t need to take into account daylight savings or leap days when dealing with unixtime.