Skip to content

Polyfill: Looking one year ahead isn't long enough to assume no transitions after that #2564

@justingrant

Description

@justingrant

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.

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;
}
}

Metadata

Metadata

Assignees

Labels

no-spec-textPR can be ignored by implementorsnon-prod-polyfillTHIS POLYFILL IS NOT FOR PRODUCTION USE!

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions