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

[Temporal] Add withPlainDate to ZonedDateTime

Spec Text:
https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.withplaindate

Bug: v8:11544
Change-Id: I8d7099906c04eae0e29ff0dabd48b736a07305d6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3692432
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80984}
parent fdde51c6
...@@ -68,8 +68,6 @@ TO_BE_IMPLEMENTED(TemporalZonedDateTimeFrom) ...@@ -68,8 +68,6 @@ TO_BE_IMPLEMENTED(TemporalZonedDateTimeFrom)
TO_BE_IMPLEMENTED(TemporalZonedDateTimeCompare) TO_BE_IMPLEMENTED(TemporalZonedDateTimeCompare)
/* Temporal #sec-temporal.zoneddatetime.prototype.with */ /* Temporal #sec-temporal.zoneddatetime.prototype.with */
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWith) TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWith)
/* Temporal #sec-temporal.zoneddatetime.prototype.withplaindate */
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainDate)
/* Temporal #sec-temporal.zoneddatetime.prototype.until */ /* Temporal #sec-temporal.zoneddatetime.prototype.until */
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeUntil) TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeUntil)
/* Temporal #sec-temporal.zoneddatetime.prototype.since */ /* Temporal #sec-temporal.zoneddatetime.prototype.since */
...@@ -585,6 +583,7 @@ TEMPORAL_ZONED_DATE_TIME_GET_BY_FORWARD_TIME_ZONE_AND_CALENDAR(MonthsInYear) ...@@ -585,6 +583,7 @@ TEMPORAL_ZONED_DATE_TIME_GET_BY_FORWARD_TIME_ZONE_AND_CALENDAR(MonthsInYear)
TEMPORAL_ZONED_DATE_TIME_GET_BY_FORWARD_TIME_ZONE_AND_CALENDAR(InLeapYear) TEMPORAL_ZONED_DATE_TIME_GET_BY_FORWARD_TIME_ZONE_AND_CALENDAR(InLeapYear)
TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, HoursInDay, hoursInDay) TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, HoursInDay, hoursInDay)
TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithCalendar, withCalendar) TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithCalendar, withCalendar)
TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithPlainDate, withPlainDate)
TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithPlainTime, withPlainTime) TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithPlainTime, withPlainTime)
TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithTimeZone, withTimeZone) TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithTimeZone, withTimeZone)
TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, ToPlainYearMonth, toPlainYearMonth) TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, ToPlainYearMonth, toPlainYearMonth)
......
...@@ -11323,6 +11323,82 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithCalendar( ...@@ -11323,6 +11323,82 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithCalendar(
return CreateTemporalZonedDateTime(isolate, nanoseconds, time_zone, calendar); return CreateTemporalZonedDateTime(isolate, nanoseconds, time_zone, calendar);
} }
// #sec-temporal.zoneddatetime.prototype.withplaindate
MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithPlainDate(
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time,
Handle<Object> plain_date_like) {
TEMPORAL_ENTER_FUNC();
const char* method_name = "Temporal.ZonedDateTime.prototype.withPlainDate";
// 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime,
// [[InitializedTemporalZonedDateTime]]).
// 3. Let plainDate be ? ToTemporalDate(plainDateLike).
Handle<JSTemporalPlainDate> plain_date;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, plain_date,
ToTemporalDate(isolate, plain_date_like, method_name),
JSTemporalZonedDateTime);
// 4. Let timeZone be zonedDateTime.[[TimeZone]].
Handle<JSReceiver> time_zone(zoned_date_time->time_zone(), isolate);
// 5. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
Handle<JSTemporalInstant> instant =
temporal::CreateTemporalInstant(
isolate, handle(zoned_date_time->nanoseconds(), isolate))
.ToHandleChecked();
// 6. Let plainDateTime be ?
// temporal::BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant,
// zonedDateTime.[[Calendar]]).
Handle<JSTemporalPlainDateTime> plain_date_time;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, plain_date_time,
temporal::BuiltinTimeZoneGetPlainDateTimeFor(
isolate, time_zone, instant,
handle(zoned_date_time->calendar(), isolate), method_name),
JSTemporalZonedDateTime);
// 7. Let calendar be ? ConsolidateCalendars(zonedDateTime.[[Calendar]],
// plainDate.[[Calendar]]).
Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar,
ConsolidateCalendars(isolate,
handle(zoned_date_time->calendar(), isolate),
handle(plain_date->calendar(), isolate)),
JSTemporalZonedDateTime);
// 8. Let resultPlainDateTime be ?
// CreateTemporalDateTime(plainDate.[[ISOYear]], plainDate.[[ISOMonth]],
// plainDate.[[ISODay]], plainDateTime.[[ISOHour]],
// plainDateTime.[[ISOMinute]], plainDateTime.[[ISOSecond]],
// plainDateTime.[[ISOMillisecond]], plainDateTime.[[ISOMicrosecond]],
// plainDateTime.[[ISONanosecond]], calendar).
Handle<JSTemporalPlainDateTime> result_plain_date_time;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, result_plain_date_time,
temporal::CreateTemporalDateTime(
isolate,
{{plain_date->iso_year(), plain_date->iso_month(),
plain_date->iso_day()},
{plain_date_time->iso_hour(), plain_date_time->iso_minute(),
plain_date_time->iso_second(), plain_date_time->iso_millisecond(),
plain_date_time->iso_microsecond(),
plain_date_time->iso_nanosecond()}},
calendar),
JSTemporalZonedDateTime);
// 9. Set instant to ? BuiltinTimeZoneGetInstantFor(timeZone,
// resultPlainDateTime, "compatible").
ASSIGN_RETURN_ON_EXCEPTION(
isolate, instant,
BuiltinTimeZoneGetInstantFor(isolate, time_zone, result_plain_date_time,
Disambiguation::kCompatible, method_name),
JSTemporalZonedDateTime);
// 10. Return ? CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone,
// calendar).
return CreateTemporalZonedDateTime(
isolate, handle(instant->nanoseconds(), isolate), time_zone, calendar);
}
// #sec-temporal.zoneddatetime.prototype.withplaintime // #sec-temporal.zoneddatetime.prototype.withplaintime
MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithPlainTime( MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithPlainTime(
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time, Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time,
......
...@@ -759,6 +759,12 @@ class JSTemporalZonedDateTime ...@@ -759,6 +759,12 @@ class JSTemporalZonedDateTime
Handle<JSTemporalZonedDateTime> zoned_date_time, Handle<JSTemporalZonedDateTime> zoned_date_time,
Handle<Object> calendar_like); Handle<Object> calendar_like);
// #sec-temporal.zoneddatetime.prototype.withplaindate
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalZonedDateTime>
WithPlainDate(Isolate* isolate,
Handle<JSTemporalZonedDateTime> zoned_date_time,
Handle<Object> plain_date_like);
// #sec-temporal.zoneddatetime.prototype.withplaintime // #sec-temporal.zoneddatetime.prototype.withplaintime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalZonedDateTime> V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalZonedDateTime>
WithPlainTime(Isolate* isolate, WithPlainTime(Isolate* isolate,
......
...@@ -1306,23 +1306,6 @@ ...@@ -1306,23 +1306,6 @@
'built-ins/Temporal/ZonedDateTime/prototype/with/overflow-invalid-string': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/with/overflow-invalid-string': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/with/overflow-undefined': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/with/overflow-undefined': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/with/overflow-wrong-type': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/with/overflow-wrong-type': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-plaindatetime': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-with-utc-designator': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/branding': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-datefromfields-called-with-options-undefined': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-fields-iterable': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-temporal-object': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/infinity-throws-rangeerror': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/negative-epochnanoseconds': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/subclassing-ignored': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/with/read-time-fields-before-datefromfields': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/with/read-time-fields-before-datefromfields': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken': [FAIL],
...@@ -1392,7 +1375,6 @@ ...@@ -1392,7 +1375,6 @@
'intl402/Temporal/ZonedDateTime/prototype/toLocaleString/options-conflict': [FAIL], 'intl402/Temporal/ZonedDateTime/prototype/toLocaleString/options-conflict': [FAIL],
'intl402/Temporal/ZonedDateTime/prototype/toLocaleString/options-undefined': [FAIL], 'intl402/Temporal/ZonedDateTime/prototype/toLocaleString/options-undefined': [FAIL],
'intl402/Temporal/ZonedDateTime/prototype/until/infinity-throws-rangeerror': [FAIL], 'intl402/Temporal/ZonedDateTime/prototype/until/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/ZonedDateTime/prototype/withPlainDate/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/Duration/prototype/add/relativeto-string-datetime': [FAIL], 'intl402/Temporal/Duration/prototype/add/relativeto-string-datetime': [FAIL],
'intl402/Temporal/Duration/prototype/round/relativeto-string-datetime': [FAIL], 'intl402/Temporal/Duration/prototype/round/relativeto-string-datetime': [FAIL],
'intl402/Temporal/Duration/prototype/subtract/relativeto-string-datetime': [FAIL], 'intl402/Temporal/Duration/prototype/subtract/relativeto-string-datetime': [FAIL],
...@@ -1607,7 +1589,6 @@ ...@@ -1607,7 +1589,6 @@
'built-ins/Temporal/ZonedDateTime/prototype/until/largestunit-smallestunit-mismatch': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/until/largestunit-smallestunit-mismatch': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/until/year-zero': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/until/year-zero': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/with/copy-properties-not-undefined': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/with/copy-properties-not-undefined': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-no-implicit-midnight': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-with-time-designator': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-with-time-designator': [FAIL],
...@@ -1633,7 +1614,6 @@ ...@@ -1633,7 +1614,6 @@
'built-ins/Temporal/PlainDateTime/prototype/until/units-changed': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/units-changed': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/weeks-months-mutually-exclusive': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/until/weeks-months-mutually-exclusive': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/weekOfYear/basic': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/weekOfYear/basic': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-invalid': [FAIL],
'built-ins/Temporal/Duration/compare/options-wrong-type': [FAIL], 'built-ins/Temporal/Duration/compare/options-wrong-type': [FAIL],
'built-ins/Temporal/Duration/prototype/add/options-wrong-type': [FAIL], 'built-ins/Temporal/Duration/prototype/add/options-wrong-type': [FAIL],
...@@ -1899,10 +1879,7 @@ ...@@ -1899,10 +1879,7 @@
'built-ins/Temporal/ZonedDateTime/prototype/until/argument-wrong-type': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/until/argument-wrong-type': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/until/timezone-wrong-type': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/until/timezone-wrong-type': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-number': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-number': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-number': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-number': [FAIL], 'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-number': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-wrong-type': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-wrong-type': [FAIL],
'built-ins/Temporal/ZonedDateTime/timezone-string-multiple-offsets': [FAIL], 'built-ins/Temporal/ZonedDateTime/timezone-string-multiple-offsets': [FAIL],
'intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-number': [FAIL], 'intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-number': [FAIL],
'intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-number': [FAIL], 'intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-number': [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