diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index 97836600f..c3bd59c8f 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -1494,9 +1494,20 @@ export function InterpretISODateTimeOffset( // "prefer" or "reject" const possibleEpochNs = GetPossibleEpochNanoseconds(timeZone, dt); if (possibleEpochNs.length > 0) { + const utcEpochNs = GetUTCEpochNanoseconds( + year, + month, + day, + time.hour, + time.minute, + time.second, + time.millisecond, + time.microsecond, + time.nanosecond + ); for (let index = 0; index < possibleEpochNs.length; index++) { const candidate = possibleEpochNs[index]; - const candidateOffset = GetOffsetNanosecondsFor(timeZone, candidate); + const candidateOffset = utcEpochNs - candidate; const roundedCandidateOffset = RoundNumberToIncrement(candidateOffset, 60e9, 'halfExpand'); if (candidateOffset === offsetNs || (matchMinute && roundedCandidateOffset === offsetNs)) { return candidate; diff --git a/spec/zoneddatetime.html b/spec/zoneddatetime.html index c401913d7..826e08a05 100644 --- a/spec/zoneddatetime.html +++ b/spec/zoneddatetime.html @@ -992,8 +992,9 @@

1. Assert: _offsetOption_ is *"prefer"* or *"reject"*. 1. Let _possibleEpochNs_ be ? GetPossibleEpochNanoseconds(_timeZone_, _isoDateTime_). 1. If _possibleEpochNs_ is not empty, then + 1. Let _utcEpochNanoseconds_ be GetUTCEpochNanoseconds(_year_, _month_, _day_, _time_.[[Hour]], _time_.[[Minute]], _time_.[[Second]], _time_.[[Millisecond]], _time_.[[Microsecond]], _time_.[[Nanosecond]]). 1. For each element _candidate_ of _possibleEpochNs_, do - 1. Let _candidateOffset_ be GetOffsetNanosecondsFor(_timeZone_, _candidate_). + 1. Let _candidateOffset_ be _utcEpochNanoseconds_ - _candidate_. 1. If _candidateOffset_ = _offsetNanoseconds_, then 1. Return _candidate_. 1. If _matchBehaviour_ is ~match-minutes~, then