From f5ef68dead4d27e3c59901d40f7e571ca1033d33 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Mon, 29 Aug 2022 20:30:07 -0700 Subject: [PATCH] [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 Commit-Queue: Frank Tang Cr-Commit-Position: refs/heads/main@{#82802} --- src/objects/js-temporal-objects.cc | 22 ++++++++++++++-------- test/test262/test262.status | 1 - 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/objects/js-temporal-objects.cc b/src/objects/js-temporal-objects.cc index 120547e2e8..3d4777b277 100644 --- a/src/objects/js-temporal-objects.cc +++ b/src/objects/js-temporal-objects.cc @@ -11241,21 +11241,27 @@ MaybeHandle JSTemporalTimeZone::GetPossibleInstantsFor( // dateTime.[[ISONanosecond]]). Handle epoch_nanoseconds = 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 // RangeError exception. if (!IsValidEpochNanoseconds(isolate, epoch_nanoseconds)) { THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALID_ARG_RANGE_ERROR(), JSArray); } - // b. Let instant be ! CreateTemporalInstant(epochNanoseconds − - // timeZone.[[OffsetNanoseconds]]). + // b. Let instant be ! CreateTemporalInstant(epochNanoseconds). + Handle instant = - temporal::CreateTemporalInstant( - isolate, - BigInt::Subtract( - isolate, epoch_nanoseconds, - BigInt::FromInt64(isolate, time_zone->offset_nanoseconds())) - .ToHandleChecked()) + temporal::CreateTemporalInstant(isolate, epoch_nanoseconds) .ToHandleChecked(); // c. Return ! CreateArrayFromList(« instant »). Handle fixed_array = factory->NewFixedArray(1); diff --git a/test/test262/test262.status b/test/test262/test262.status index e761a061a2..d0bd12edd2 100644 --- a/test/test262/test262.status +++ b/test/test262/test262.status @@ -681,7 +681,6 @@ '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/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/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL],