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

[Temporal] Add PlainDateTime.prototype.toPlain(Date|Time)

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

Bug: v8:11544
Change-Id: Ifb7115823d1d3d1ff53806f1b376d69302e00ae1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3385761Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80731}
parent 38e56036
......@@ -100,10 +100,6 @@ TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToLocaleString)
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToString)
/* Temporal #sec-temporal.plainddatetimeprototype.tojson */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToJSON)
/* Temporal #sec-temporal.plaindatetime.prototype.toplaindate */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainDate)
/* Temporal #sec-temporal.plaindatetime.prototype.toplaintime */
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainTime)
/* Temporal.ZonedDateTime */
/* Temporal #sec-temporal.zoneddatetime.from */
......@@ -488,6 +484,8 @@ TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, ToPlainMonthDay, toPlainMonthDay)
TEMPORAL_PROTOTYPE_METHOD2(PlainDateTime, ToZonedDateTime, toZonedDateTime)
TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, GetISOFields, getISOFields)
TEMPORAL_VALUE_OF(PlainDateTime)
TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, ToPlainDate, toPlainDate)
TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, ToPlainTime, toPlainTime)
// PlainYearMonth
BUILTIN(TemporalPlainYearMonthConstructor) {
......
......@@ -8715,6 +8715,36 @@ MaybeHandle<JSReceiver> JSTemporalPlainDateTime::GetISOFields(
return fields;
}
// #sec-temporal.plaindatetime.prototype.toplaindate
MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDateTime::ToPlainDate(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time) {
// 1. Let dateTime be the this value.
// 2. Perform ? RequireInternalSlot(dateTime,
// [[InitializedTemporalDateTime]]).
// 3. Return ? CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]],
// dateTime.[[ISODay]], dateTime.[[Calendar]]).
return CreateTemporalDate(
isolate,
{date_time->iso_year(), date_time->iso_month(), date_time->iso_day()},
Handle<JSReceiver>(date_time->calendar(), isolate));
}
// #sec-temporal.plaindatetime.prototype.toplaintime
MaybeHandle<JSTemporalPlainTime> JSTemporalPlainDateTime::ToPlainTime(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time) {
// 1. Let dateTime be the this value.
// 2. Perform ? RequireInternalSlot(dateTime,
// [[InitializedTemporalDateTime]]).
// 3. Return ? CreateTemporalTime(dateTime.[[ISOHour]],
// dateTime.[[ISOMinute]], dateTime.[[ISOSecond]],
// dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]],
// dateTime.[[ISONanosecond]]).
return CreateTemporalTime(
isolate, {date_time->iso_hour(), date_time->iso_minute(),
date_time->iso_second(), date_time->iso_millisecond(),
date_time->iso_microsecond(), date_time->iso_nanosecond()});
}
// #sec-temporal.plainmonthday
MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainMonthDay::Constructor(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
......
......@@ -378,6 +378,14 @@ class JSTemporalPlainDateTime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDateTime> NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like);
// #sec-temporal.plaindatetime.prototype.toplaindate
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> ToPlainDate(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time);
// #sec-temporal.plaindatetime.prototype.toplaintime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainTime> ToPlainTime(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time);
DECL_PRINTER(JSTemporalPlainDateTime)
DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY()
......
......@@ -68,8 +68,6 @@
'temporal/plain-date-time-equals': [FAIL],
'temporal/plain-date-time-subtract': [FAIL],
'temporal/plain-date-time-to-json': [FAIL],
'temporal/plain-date-time-to-plain-date': [FAIL],
'temporal/plain-date-time-to-plain-time': [FAIL],
'temporal/plain-date-time-with': [FAIL],
'temporal/plain-date-time-with-plain-date': [FAIL],
'temporal/plain-date-to-plain-date-time': [FAIL],
......
......@@ -942,9 +942,7 @@
'built-ins/Temporal/PlainDateTime/prototype/toJSON/year-format': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toLocaleString/branding': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toLocaleString/return-string': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainDate/branding': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainDate/limits': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainTime/branding': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/branding': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-invalid-string': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined': [FAIL],
......@@ -1801,7 +1799,6 @@
'built-ins/Temporal/PlainDateTime/prototype/since/largestunit-smallestunit-mismatch': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/since/year-zero': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/subtract/argument-string-fractional-units-rounding-mode': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/toPlainTime/basic': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/largestunit-smallestunit-mismatch': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/until/year-zero': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/with/copy-properties-not-undefined': [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