Commit 05f3596f authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ

[Temporal] Add PlainDateTime.prototype.toZonedDateTime

Spec Text:
https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.tozoneddatetime

Bug: v8:11544
Change-Id: Ic4464e6d4521fb7e006164933df4f38c5d3115b1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3554666
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80685}
parent a90169d3
...@@ -110,8 +110,6 @@ TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToLocaleString) ...@@ -110,8 +110,6 @@ TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToLocaleString)
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToString) TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToString)
/* Temporal #sec-temporal.plainddatetimeprototype.tojson */ /* Temporal #sec-temporal.plainddatetimeprototype.tojson */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToJSON) TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToJSON)
/* Temporal #sec-temporal.plaindatetime.prototype.tozoneddatetime */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToZonedDateTime)
/* Temporal #sec-temporal.plaindatetime.prototype.toplaindate */ /* Temporal #sec-temporal.plaindatetime.prototype.toplaindate */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainDate) TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainDate)
/* Temporal #sec-temporal.plaindatetime.prototype.toplaintime */ /* Temporal #sec-temporal.plaindatetime.prototype.toplaintime */
...@@ -496,6 +494,7 @@ TEMPORAL_GET_SMI(PlainDateTime, Nanosecond, iso_nanosecond) ...@@ -496,6 +494,7 @@ TEMPORAL_GET_SMI(PlainDateTime, Nanosecond, iso_nanosecond)
TEMPORAL_METHOD2(PlainDateTime, From) TEMPORAL_METHOD2(PlainDateTime, From)
TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, ToPlainYearMonth, toPlainYearMonth) TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, ToPlainYearMonth, toPlainYearMonth)
TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, ToPlainMonthDay, toPlainMonthDay) TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, ToPlainMonthDay, toPlainMonthDay)
TEMPORAL_PROTOTYPE_METHOD2(PlainDateTime, ToZonedDateTime, toZonedDateTime)
TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, GetISOFields, getISOFields) TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, GetISOFields, getISOFields)
TEMPORAL_VALUE_OF(PlainDateTime) TEMPORAL_VALUE_OF(PlainDateTime)
......
...@@ -8245,6 +8245,48 @@ MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainDateTime::ToPlainMonthDay( ...@@ -8245,6 +8245,48 @@ MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainDateTime::ToPlainMonthDay(
isolate->factory()->monthCode_string()); isolate->factory()->monthCode_string());
} }
// #sec-temporal.plaindatetime.prototype.tozoneddatetime
MaybeHandle<JSTemporalZonedDateTime> JSTemporalPlainDateTime::ToZonedDateTime(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time,
Handle<Object> temporal_time_zone_like, Handle<Object> options_obj) {
const char* method_name = "Temporal.PlainDateTime.prototype.toZonedDateTime";
// 1. Let dateTime be the this value.
// 2. Perform ? RequireInternalSlot(dateTime,
// [[InitializedTemporalDateTime]]).
// 3. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
Handle<JSReceiver> time_zone;
ASSIGN_RETURN_ON_EXCEPTION(isolate, time_zone,
temporal::ToTemporalTimeZone(
isolate, temporal_time_zone_like, method_name),
JSTemporalZonedDateTime);
// 4. Set options to ? GetOptionsObject(options).
Handle<JSReceiver> options;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, options, GetOptionsObject(isolate, options_obj, method_name),
JSTemporalZonedDateTime);
// 5. Let disambiguation be ? ToTemporalDisambiguation(options).
Disambiguation disambiguation;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, disambiguation,
ToTemporalDisambiguation(isolate, options, method_name),
Handle<JSTemporalZonedDateTime>());
// 6. Let instant be ? BuiltinTimeZoneGetInstantFor(timeZone, dateTime,
// disambiguation).
Handle<JSTemporalInstant> instant;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, instant,
BuiltinTimeZoneGetInstantFor(isolate, time_zone, date_time,
disambiguation, method_name),
JSTemporalZonedDateTime);
// 7. Return ? CreateTemporalZonedDateTime(instant.[[Nanoseconds]],
// timeZone, dateTime.[[Calendar]]).
return CreateTemporalZonedDateTime(
isolate, Handle<BigInt>(instant->nanoseconds(), isolate), time_zone,
Handle<JSReceiver>(date_time->calendar(), isolate));
}
// #sec-temporal.now.plaindatetime // #sec-temporal.now.plaindatetime
MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Now( MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Now(
Isolate* isolate, Handle<Object> calendar_like, Isolate* isolate, Handle<Object> calendar_like,
......
...@@ -339,6 +339,12 @@ class JSTemporalPlainDateTime ...@@ -339,6 +339,12 @@ class JSTemporalPlainDateTime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainMonthDay> V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainMonthDay>
ToPlainMonthDay(Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time); ToPlainMonthDay(Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time);
// #sec-temporal.plaintime.prototype.tozoneddatetime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalZonedDateTime>
ToZonedDateTime(Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time,
Handle<Object> temporal_time_zone_like,
Handle<Object> options_obj);
// #sec-temporal.plaindatetime.prototype.getisofields // #sec-temporal.plaindatetime.prototype.getisofields
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields( V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time); Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time);
......
...@@ -996,19 +996,10 @@ ...@@ -996,19 +996,10 @@
'built-ins/Temporal/PlainDateTime/prototype/toString/smallestunit-valid-units': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toString/smallestunit-valid-units': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/smallestunit-wrong-type': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toString/smallestunit-wrong-type': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/year-format': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toString/year-format': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/balance-negative-time-units': [SKIP], 'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/balance-negative-time-units': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/branding': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-undefined': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-invalid-string': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-undefined': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-undefined': [SKIP], 'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-wrong-type': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-undefined': [SKIP],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/plain-custom-timezone': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable': [SKIP],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-multiple-offsets': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/argument-plaindate': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/argument-plaindate': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/argument-string-with-utc-designator': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/argument-string-with-utc-designator': [FAIL],
...@@ -2252,7 +2243,6 @@ ...@@ -2252,7 +2243,6 @@
'built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfExpand': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-halfExpand': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-trunc': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toString/roundingmode-trunc': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/smallestunit-fractionalseconddigits': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toString/smallestunit-fractionalseconddigits': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-wrong-type': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/argument-object': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/argument-object': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/argument-string': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/argument-string': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/options-empty': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/options-empty': [FAIL],
...@@ -2411,11 +2401,8 @@ ...@@ -2411,11 +2401,8 @@
'built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-wrong-type': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-wrong-type': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/since/argument-wrong-type': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/since/argument-wrong-type': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/subtract/limits': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/subtract/limits': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/basic': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/invalid-instant': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/invalid-instant': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/multiple-instants': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/multiple-instants': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-object': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-wrong-type': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/argument-number': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/argument-number': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-number': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-number': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-wrong-type': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-wrong-type': [FAIL],
......
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