-
Notifications
You must be signed in to change notification settings - Fork 171
Description
The optimization in the code below (from 20ef40b) probably isn't correct, because when a well-run country makes a planned time zone change (e.g. stopping or changing use of DST), those changes should be announced more than a year in advance to give time for software to be updated before the change happens.
Sadly, not all countries are well-run in that way, but I think we should be more conservative to avoid breaking Test262 tests if a well-run country decides to do this.
So I'd recommend changing it from one year to a few years, maybe 4-5 years? I strongly doubt that any country announces changes more than 5 years in advance, because politicians like to claim credit sooner! Honestly 2-3 years is probably enough, but the perf cost of a few years is small, so might as well go for 5 years.
proposal-temporal/polyfill/lib/ecmascript.mjs
Lines 2729 to 2740 in ca103d6
| export function GetNamedTimeZonePreviousTransition(id, epochNanoseconds) { | |
| // Optimization: if the instant is more than a year in the future and there | |
| // are no transitions between the present day and a year from now, assume | |
| // there are none after | |
| const now = SystemUTCEpochNanoSeconds(); | |
| const yearLater = now.plus(DAY_NANOS.multiply(366)); | |
| if (epochNanoseconds.gt(yearLater)) { | |
| const prevBeforeNextYear = GetNamedTimeZonePreviousTransition(id, yearLater); | |
| if (prevBeforeNextYear === null || prevBeforeNextYear.lt(now)) { | |
| return prevBeforeNextYear; | |
| } | |
| } |