Skip to content

Commit

Permalink
Possible for InterpretISODateTimeOffset to call GetOffsetNanosecondsF…
Browse files Browse the repository at this point in the history
…or fewer times for prefer/reject
  • Loading branch information
arshaw committed Feb 27, 2024
1 parent 2ff1ed3 commit 8c1b2c9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1558,12 +1558,24 @@ export function InterpretISODateTimeOffset(
// "prefer" or "reject"
const possibleInstants = GetPossibleInstantsFor(timeZoneRec, dt);
if (possibleInstants.length > 0) {
const utcEpochNs = GetUTCEpochNanoseconds(
year,
month,
day,
hour,
minute,
second,
millisecond,
microsecond,
nanosecond
);
for (let index = 0; index < possibleInstants.length; index++) {
const candidate = possibleInstants[index];
const candidateOffset = GetOffsetNanosecondsFor(timeZoneRec, candidate);
const candidateEpochNs = GetSlot(candidate, EPOCHNANOSECONDS);
const candidateOffset = utcEpochNs - candidateEpochNs;
const roundedCandidateOffset = RoundNumberToIncrement(bigInt(candidateOffset), 60e9, 'halfExpand').toJSNumber();
if (candidateOffset === offsetNs || (matchMinute && roundedCandidateOffset === offsetNs)) {
return GetSlot(candidate, EPOCHNANOSECONDS);
return candidateEpochNs;
}
}
}
Expand Down

0 comments on commit 8c1b2c9

Please sign in to comment.