[Temporal] Fix TimeZone getPossibleInstantsFor

Subtract timeZone.[[OffsetNanoseconds]] from epochNanoseconds
before calling the IsValidEpochNanoseconds() for the case of
4. If timeZone.[[OffsetNanoseconds]] is not undefined

Bug: v8:11544
Change-Id: Icea2d8390a9db01054956f8c57b47dc5a88446d4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3855980
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82802}
This commit is contained in:
Frank Tang 2022-08-29 20:30:07 -07:00 committed by V8 LUCI CQ
parent 0f901f00e8
commit f5ef68dead
2 changed files with 14 additions and 9 deletions

View File

@ -11241,21 +11241,27 @@ MaybeHandle<JSArray> JSTemporalTimeZone::GetPossibleInstantsFor(
// dateTime.[[ISONanosecond]]). // dateTime.[[ISONanosecond]]).
Handle<BigInt> epoch_nanoseconds = Handle<BigInt> epoch_nanoseconds =
GetEpochFromISOParts(isolate, date_time_record); GetEpochFromISOParts(isolate, date_time_record);
// b. Let possibleEpochNanoseconds be « epochNanoseconds -
// (timeZone.[[OffsetNanoseconds]]) ».
epoch_nanoseconds =
BigInt::Subtract(
isolate, epoch_nanoseconds,
BigInt::FromInt64(isolate, time_zone->offset_nanoseconds()))
.ToHandleChecked();
// The following is the step 7 and 8 for the case of step 4 under the if
// block.
// a. If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a // a. If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a
// RangeError exception. // RangeError exception.
if (!IsValidEpochNanoseconds(isolate, epoch_nanoseconds)) { if (!IsValidEpochNanoseconds(isolate, epoch_nanoseconds)) {
THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALID_ARG_RANGE_ERROR(), JSArray); THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALID_ARG_RANGE_ERROR(), JSArray);
} }
// b. Let instant be ! CreateTemporalInstant(epochNanoseconds // b. Let instant be ! CreateTemporalInstant(epochNanoseconds).
// timeZone.[[OffsetNanoseconds]]).
Handle<JSTemporalInstant> instant = Handle<JSTemporalInstant> instant =
temporal::CreateTemporalInstant( temporal::CreateTemporalInstant(isolate, epoch_nanoseconds)
isolate,
BigInt::Subtract(
isolate, epoch_nanoseconds,
BigInt::FromInt64(isolate, time_zone->offset_nanoseconds()))
.ToHandleChecked())
.ToHandleChecked(); .ToHandleChecked();
// c. Return ! CreateArrayFromList(« instant »). // c. Return ! CreateArrayFromList(« instant »).
Handle<FixedArray> fixed_array = factory->NewFixedArray(1); Handle<FixedArray> fixed_array = factory->NewFixedArray(1);

View File

@ -681,7 +681,6 @@
'built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-with-fractional-days': [FAIL], 'built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-with-fractional-days': [FAIL],
'built-ins/Temporal/PlainTime/prototype/add/argument-string-duration-too-large': [FAIL], 'built-ins/Temporal/PlainTime/prototype/add/argument-string-duration-too-large': [FAIL],
'built-ins/Temporal/PlainTime/prototype/subtract/argument-string-duration-too-large': [FAIL], 'built-ins/Temporal/PlainTime/prototype/subtract/argument-string-duration-too-large': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/fixed-offset-near-date-time-limits': [FAIL],
'intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition': [FAIL], 'intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition': [FAIL],
'intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL], 'intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL],