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

[Temporal] Add PlainDate toPlainDateTime

Spec Text: https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.toplaindatetime

Bug: v8:11544
Change-Id: Ie86a5d8a2f1206a44d0e74638392ae26e0f8e900
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3534454Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80707}
parent 3c53e9ad
......@@ -52,8 +52,6 @@ TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeUntil)
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeSince)
/* Temporal #sec-temporal.plaindate.prototype.equals */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeEquals)
/* Temporal #sec-temporal.plaindate.prototype.toplaindatetime */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainDateTime)
/* Temporal #sec-temporal.plaindate.prototype.tozoneddatetime */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToZonedDateTime)
......@@ -421,6 +419,7 @@ TEMPORAL_PROTOTYPE_METHOD0(PlainDate, ToPlainYearMonth, toPlainYearMonth)
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, ToPlainMonthDay, toPlainMonthDay)
TEMPORAL_PROTOTYPE_METHOD1(PlainDate, WithCalendar, withCalendar)
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, GetISOFields, getISOFields)
TEMPORAL_PROTOTYPE_METHOD1(PlainDate, ToPlainDateTime, toPlainDateTime)
TEMPORAL_VALUE_OF(PlainDate)
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, ToJSON, toJSON)
TEMPORAL_PROTOTYPE_METHOD2(PlainDate, ToLocaleString, toLocaleString)
......
......@@ -7741,6 +7741,49 @@ MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainDate::ToPlainMonthDay(
isolate->factory()->monthCode_string());
}
// #sec-temporal.plaindate.prototype.toplaindatetime
MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDate::ToPlainDateTime(
Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date,
Handle<Object> temporal_time_obj) {
// 1. Let temporalDate be the this value.
// 2. Perform ? RequireInternalSlot(temporalDate,
// [[InitializedTemporalDate]]).
// 3. If temporalTime is undefined, then
if (temporal_time_obj->IsUndefined()) {
// a. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]],
// temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], 0, 0, 0, 0, 0, 0,
// temporalDate.[[Calendar]]).
return temporal::CreateTemporalDateTime(
isolate,
{{temporal_date->iso_year(), temporal_date->iso_month(),
temporal_date->iso_day()},
{0, 0, 0, 0, 0, 0}},
Handle<JSReceiver>(temporal_date->calendar(), isolate));
}
// 4. Set temporalTime to ? ToTemporalTime(temporalTime).
Handle<JSTemporalPlainTime> temporal_time;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, temporal_time,
temporal::ToTemporalTime(isolate, temporal_time_obj,
ShowOverflow::kConstrain,
"Temporal.PlainDate.prototype.toPlainDateTime"),
JSTemporalPlainDateTime);
// 5. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]],
// temporalDate.[[ISOMonth]], temporalDate.[[ISODay]],
// temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]],
// temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]],
// temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]],
// temporalDate.[[Calendar]]).
return temporal::CreateTemporalDateTime(
isolate,
{{temporal_date->iso_year(), temporal_date->iso_month(),
temporal_date->iso_day()},
{temporal_time->iso_hour(), temporal_time->iso_minute(),
temporal_time->iso_second(), temporal_time->iso_millisecond(),
temporal_time->iso_microsecond(), temporal_time->iso_nanosecond()}},
Handle<JSReceiver>(temporal_date->calendar(), isolate));
}
// #sec-temporal.now.plaindate
MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Now(
Isolate* isolate, Handle<Object> calendar_like,
......
......@@ -261,6 +261,10 @@ class JSTemporalPlainDate
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date,
Handle<Object> calendar_like);
// #sec-temporal.plaindate.prototype.toplaindatetime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDateTime>
ToPlainDateTime(Isolate* isolate, Handle<JSTemporalPlainDate> plain_date,
Handle<Object> temporal_time);
// #sec-temporal.plaindate.from
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> From(
Isolate* isolate, Handle<Object> item, Handle<Object> options);
......
......@@ -778,19 +778,8 @@
'built-ins/Temporal/PlainDate/prototype/subtract/overflow-undefined': [FAIL],
'built-ins/Temporal/PlainDate/prototype/subtract/overflow-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/subtract/subclassing-ignored': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-with-utc-designator': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-balance-negative-time-units': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-negative-epochnanoseconds': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/basic': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/branding': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/calendar-temporal-object': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/plaintime-propertybag-no-time-units': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/time-invalid': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/time-undefined': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-with-utc-designator': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-zoneddatetime-negative-epochnanoseconds': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/basic': [FAIL],
......@@ -2333,8 +2322,6 @@
'built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-number': [FAIL],
'built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/since/argument-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-number': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-wrong-type': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/limits': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-number': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-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