Commit 187ecb8b authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ

Reland "[Temporal] Add TimeZone get*Transition and getPlainDateTimeFor"

This is a reland of commit 4251c285

Change the test262.status by moving test which passing on no_i18n
but not on ALWAYS:
1) Change the [FAIL] of that test in the ALWAYS section to [SKIP].
2) Add the same test the no_i18n section as [PASS]

Original change's description:
> [Temporal] Add TimeZone get*Transition and getPlainDateTimeFor
>
> Also add non-intl (only support UTC) version of AO:
> GetIANATimeZoneNextTransition, GetIANATimeZonePreviousTransition
> (support of other timezone in Intl will come later)
>
> Spec Text:
> https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getplaindatetimefor
> https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getnexttransition
> https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getprevioustransition
> https://tc39.es/proposal-temporal/#sec-temporal-getianatimezonenexttransition
> https://tc39.es/proposal-temporal/#sec-temporal-getianatimezoneprevioustransition
>
>
> Bug: v8:11544
> Change-Id: I17d5a60638dcd8543e5d9f22c6560b311f2f402a
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3534450
> Commit-Queue: Frank Tang <ftang@chromium.org>
> Reviewed-by: Adam Klein <adamk@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#80383}

Bug: v8:11544
Change-Id: Ieddadbc9d0708bda24f88dd2083b0dbe7dc1b9f3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3632607
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80405}
parent 91ab0528
......@@ -280,14 +280,8 @@ TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToPlainDate)
TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetOffsetNanosecondsFor)
/* Temporal #sec-temporal.timezone.prototype.getoffsetstringfor */
TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetOffsetStringFor)
/* Temporal #sec-temporal.timezone.prototype.getplaindatetimefor */
TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetPlainDateTimeFor)
/* Temporal #sec-temporal.timezone.prototype.getpossibleinstantsfor */
TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetPossibleInstantsFor)
/* Temporal #sec-temporal.timezone.prototype.getnexttransition */
TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetNextTransition)
/* Temporal #sec-temporal.timezone.prototype.getprevioustransition */
TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetPreviousTransition)
/* Temporal.Calendar */
/* Temporal #sec-temporal.calendar.prototype.weekofyear */
......@@ -851,6 +845,10 @@ BUILTIN(TemporalTimeZonePrototypeToString) {
isolate, JSTemporalTimeZone::ToString(isolate, time_zone, method_name));
}
TEMPORAL_PROTOTYPE_METHOD1(TimeZone, GetNextTransition, getNextTransition)
TEMPORAL_PROTOTYPE_METHOD2(TimeZone, GetPlainDateTimeFor, getPlainDateTimeFor)
TEMPORAL_PROTOTYPE_METHOD1(TimeZone, GetPreviousTransition,
getPreviousTransition)
// #sec-temporal.timezone.from
BUILTIN(TemporalTimeZoneFrom) {
HandleScope scope(isolate);
......
......@@ -6799,6 +6799,118 @@ MaybeHandle<JSTemporalInstant> JSTemporalTimeZone::GetInstantFor(
disambiguation, method_name);
}
namespace {
// #sec-temporal-getianatimezonenexttransition
MaybeHandle<Object> GetIANATimeZoneNextTransition(Isolate* isolate,
Handle<BigInt> nanoseconds,
int32_t time_zone_index) {
#ifdef V8_INTL_SUPPORT
// TODO(ftang) Add support for non UTC timezone
DCHECK_EQ(time_zone_index, 0);
return isolate->factory()->null_value();
#else // V8_INTL_SUPPORT
return isolate->factory()->null_value();
#endif // V8_INTL_SUPPORT
}
// #sec-temporal-getianatimezoneprevioustransition
MaybeHandle<Object> GetIANATimeZonePreviousTransition(
Isolate* isolate, Handle<BigInt> nanoseconds, int32_t time_zone_index) {
#ifdef V8_INTL_SUPPORT
// TODO(ftang) Add support for non UTC timezone
DCHECK_EQ(time_zone_index, 0);
return isolate->factory()->null_value();
#else // V8_INTL_SUPPORT
return isolate->factory()->null_value();
#endif // V8_INTL_SUPPORT
}
} // namespace
// #sec-temporal.timezone.prototype.getplaindatetimefor
MaybeHandle<JSTemporalPlainDateTime> JSTemporalTimeZone::GetPlainDateTimeFor(
Isolate* isolate, Handle<JSTemporalTimeZone> time_zone,
Handle<Object> instant_obj, Handle<Object> calendar_like) {
TEMPORAL_ENTER_FUNC();
const char* method_name = "Temporal.TimeZone.prototype.getPlainDateTimeFor";
// 1. 1. Let timeZone be the this value.
// 2. Perform ? RequireInternalSlot(timeZone,
// [[InitializedTemporalTimeZone]]).
// 3. Set instant to ? ToTemporalInstant(instant).
Handle<JSTemporalInstant> instant;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, instant, ToTemporalInstant(isolate, instant_obj, method_name),
JSTemporalPlainDateTime);
// 4. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar,
ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
JSTemporalPlainDateTime);
// 5. Return ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant,
// calendar).
return temporal::BuiltinTimeZoneGetPlainDateTimeFor(
isolate, time_zone, instant, calendar, method_name);
}
// template for shared code of Temporal.TimeZone.prototype.getNextTransition and
// Temporal.TimeZone.prototype.getPreviousTransition
template <MaybeHandle<Object> (*iana_func)(Isolate*, Handle<BigInt>, int32_t)>
MaybeHandle<Object> GetTransition(Isolate* isolate,
Handle<JSTemporalTimeZone> time_zone,
Handle<Object> starting_point_obj,
const char* method_name) {
TEMPORAL_ENTER_FUNC();
// 1. Let timeZone be the this value.
// 2. Perform ? RequireInternalSlot(timeZone,
// [[InitializedTemporalTimeZone]]).
// 3. Set startingPoint to ? ToTemporalInstant(startingPoint).
Handle<JSTemporalInstant> starting_point;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, starting_point,
ToTemporalInstant(isolate, starting_point_obj, method_name), Object);
// 4. If timeZone.[[OffsetNanoseconds]] is not undefined, return null.
if (time_zone->is_offset()) {
return isolate->factory()->null_value();
}
// 5. Let transition be ?
// GetIANATimeZoneNextTransition(startingPoint.[[Nanoseconds]],
// timeZone.[[Identifier]]).
Handle<Object> transition_obj;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, transition_obj,
iana_func(isolate, Handle<BigInt>(starting_point->nanoseconds(), isolate),
time_zone->time_zone_index()),
Object);
// 6. If transition is null, return null.
if (transition_obj->IsNull()) {
return isolate->factory()->null_value();
}
DCHECK(transition_obj->IsBigInt());
Handle<BigInt> transition = Handle<BigInt>::cast(transition_obj);
// 7. Return ! CreateTemporalInstant(transition).
return temporal::CreateTemporalInstant(isolate, transition);
}
// #sec-temporal.timezone.prototype.getnexttransition
MaybeHandle<Object> JSTemporalTimeZone::GetNextTransition(
Isolate* isolate, Handle<JSTemporalTimeZone> time_zone,
Handle<Object> starting_point_obj) {
return GetTransition<GetIANATimeZoneNextTransition>(
isolate, time_zone, starting_point_obj,
"Temporal.TimeZone.prototype.getNextTransition");
}
// #sec-temporal.timezone.prototype.getprevioustransition
MaybeHandle<Object> JSTemporalTimeZone::GetPreviousTransition(
Isolate* isolate, Handle<JSTemporalTimeZone> time_zone,
Handle<Object> starting_point_obj) {
return GetTransition<GetIANATimeZonePreviousTransition>(
isolate, time_zone, starting_point_obj,
"Temporal.TimeZone.prototype.getPreviousTransition");
}
// #sec-temporal.timezone.prototype.tostring
MaybeHandle<Object> JSTemporalTimeZone::ToString(
Isolate* isolate, Handle<JSTemporalTimeZone> time_zone,
......
......@@ -408,6 +408,21 @@ class JSTemporalTimeZone
Isolate* isolate, Handle<JSTemporalTimeZone> time_zone,
Handle<Object> dateTime, Handle<Object> options);
// #sec-temporal.timezone.prototype.getplaindatetimefor
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDateTime>
GetPlainDateTimeFor(Isolate* isolate, Handle<JSTemporalTimeZone> time_zone,
Handle<Object> instance, Handle<Object> calendar_like);
// #sec-temporal.timezone.prototype.getnexttransition
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetNextTransition(
Isolate* isolate, Handle<JSTemporalTimeZone> time_zone,
Handle<Object> starting_point);
// #sec-temporal.timezone.prototype.getprevioustransition
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> GetPreviousTransition(
Isolate* isolate, Handle<JSTemporalTimeZone> time_zone,
Handle<Object> starting_point);
// #sec-temporal.timezone.prototype.tostring
static MaybeHandle<Object> ToString(Isolate* isolate,
Handle<JSTemporalTimeZone> time_zone,
......
......@@ -1552,9 +1552,6 @@
'built-ins/Temporal/TimeZone/prototype/getInstantFor/disambiguation-wrong-type': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getInstantFor/options-undefined': [SKIP],
'built-ins/Temporal/TimeZone/prototype/getInstantFor/read-time-fields-before-datefromfields': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-zoneddatetime': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getNextTransition/branding': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getNextTransition/instant-string': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-not-absolute': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-zoneddatetime': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/branding': [FAIL],
......@@ -1570,20 +1567,13 @@
'built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-negative-epochnanoseconds': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-not-absolute': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-not-absolute-getOffsetNanosecondsFor-override': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-zoneddatetime': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/balance-negative-time-units': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-temporal-object': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-undefined': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/custom-timezone': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-multiple-offsets': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/pre-epoch': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-not-datetime': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-plaindate': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-with-utc-designator': [FAIL],
......@@ -1598,9 +1588,6 @@
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-temporal-object': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/infinity-throws-rangeerror': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/read-time-fields-before-datefromfields': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-zoneddatetime': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPreviousTransition/branding': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPreviousTransition/instant-string': [FAIL],
'built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
......@@ -2391,13 +2378,10 @@
'built-ins/Temporal/PlainYearMonth/prototype/with/copy-properties-not-undefined': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/with/options-wrong-type': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getNextTransition/year-zero': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/year-zero': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/year-zero': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/branding': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/year-zero': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/year-zero': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPreviousTransition/year-zero': [FAIL],
'built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-offset-not-agreeing-with-timezone': [FAIL],
'built-ins/Temporal/ZonedDateTime/compare/year-zero': [FAIL],
'built-ins/Temporal/ZonedDateTime/from/argument-propertybag-offset-not-agreeing-with-timezone': [FAIL],
......@@ -2816,7 +2800,6 @@
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-object-tostring': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-wrong-type': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-number': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-wrong-type': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-sub-minute-offset': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/limits': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-number': [FAIL],
......@@ -2998,6 +2981,8 @@
'built-ins/Temporal/Calendar/prototype/dateAdd/duration-argument-string-negative-fractional-units': [SKIP],
'built-ins/Temporal/Calendar/prototype/dateAdd/overflow-undefined': [SKIP],
'built-ins/Temporal/Calendar/prototype/dateAdd/overflow-wrong-type': [SKIP],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-wrong-type': [SKIP],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/custom-timezone': [SKIP],
# Flaky Temporal tests
'built-ins/Temporal/Instant/from/instant-string-sub-minute-offset': [SKIP],
......@@ -3217,6 +3202,7 @@
'built-ins/Temporal/Calendar/prototype/dateAdd/duration-argument-string-negative-fractional-units': [PASS],
'built-ins/Temporal/Calendar/prototype/dateAdd/overflow-undefined': [PASS],
'built-ins/Temporal/Calendar/prototype/dateAdd/overflow-wrong-type': [PASS],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-wrong-type': [PASS],
}], # no_i18n == True
['arch == arm or arch == mipsel or arch == mips or arch == arm64 or arch == mips64 or arch == mips64el', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment