[Temporal] Add PlainDate.prototype.(add|subtract)
Spec Text: https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.add https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.subtract Bug: v8:11544 Change-Id: Iacb4b9ba7d481005d14e2e4d42e2422133f5ab42 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3617389 Commit-Queue: Frank Tang <ftang@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/main@{#80955}
This commit is contained in:
parent
242bc1947c
commit
88b644717f
@ -38,10 +38,6 @@ namespace internal {
|
||||
JSTemporal##T::NowISO(isolate, args.atOrUndefined(isolate, 1))); \
|
||||
}
|
||||
|
||||
/* Temporal #sec-temporal.plaindate.prototype.add */
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeAdd)
|
||||
/* Temporal #sec-temporal.plaindate.prototype.substract */
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeSubtract)
|
||||
/* Temporal #sec-temporal.plaindate.prototype.until */
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeUntil)
|
||||
/* Temporal #sec-temporal.plaindate.prototype.since */
|
||||
@ -360,6 +356,8 @@ TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, MonthsInYear, monthsInYear)
|
||||
TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, InLeapYear, inLeapYear)
|
||||
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, ToPlainYearMonth, toPlainYearMonth)
|
||||
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, ToPlainMonthDay, toPlainMonthDay)
|
||||
TEMPORAL_PROTOTYPE_METHOD2(PlainDate, Add, add)
|
||||
TEMPORAL_PROTOTYPE_METHOD2(PlainDate, Subtract, subtract)
|
||||
TEMPORAL_PROTOTYPE_METHOD1(PlainDate, WithCalendar, withCalendar)
|
||||
TEMPORAL_PROTOTYPE_METHOD2(PlainDate, With, with)
|
||||
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, GetISOFields, getISOFields)
|
||||
|
@ -8371,6 +8371,65 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalPlainDate::ToZonedDateTime(
|
||||
isolate, handle(instant->nanoseconds(), isolate), time_zone, calendar);
|
||||
}
|
||||
|
||||
// #sec-temporal.plaindate.prototype.add
|
||||
MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Add(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date,
|
||||
Handle<Object> temporal_duration_like, Handle<Object> options_obj) {
|
||||
const char* method_name = "Temporal.PlainDate.prototype.add";
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate,
|
||||
// [[InitializedTemporalDate]]).
|
||||
// 3. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
||||
Handle<JSTemporalDuration> duration;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, duration,
|
||||
temporal::ToTemporalDuration(
|
||||
isolate, temporal_duration_like, method_name),
|
||||
JSTemporalPlainDate);
|
||||
|
||||
// 4. Set options to ? GetOptionsObject(options).
|
||||
Handle<JSReceiver> options;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, options, GetOptionsObject(isolate, options_obj, method_name),
|
||||
JSTemporalPlainDate);
|
||||
// 5. Return ? CalendarDateAdd(temporalDate.[[Calendar]], temporalDate,
|
||||
// duration, options).
|
||||
return CalendarDateAdd(isolate, handle(temporal_date->calendar(), isolate),
|
||||
temporal_date, duration, options,
|
||||
isolate->factory()->undefined_value());
|
||||
}
|
||||
|
||||
// #sec-temporal.plaindate.prototype.subtract
|
||||
MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Subtract(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date,
|
||||
Handle<Object> temporal_duration_like, Handle<Object> options_obj) {
|
||||
const char* method_name = "Temporal.PlainDate.prototype.subtract";
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate,
|
||||
// [[InitializedTemporalDate]]).
|
||||
// 3. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
||||
Handle<JSTemporalDuration> duration;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, duration,
|
||||
temporal::ToTemporalDuration(
|
||||
isolate, temporal_duration_like, method_name),
|
||||
JSTemporalPlainDate);
|
||||
|
||||
// 4. Set options to ? GetOptionsObject(options).
|
||||
Handle<JSReceiver> options;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, options, GetOptionsObject(isolate, options_obj, method_name),
|
||||
JSTemporalPlainDate);
|
||||
|
||||
// 5. Let negatedDuration be ! CreateNegatedTemporalDuration(duration).
|
||||
Handle<JSTemporalDuration> negated_duration =
|
||||
CreateNegatedTemporalDuration(isolate, duration).ToHandleChecked();
|
||||
|
||||
// 6. Return ? CalendarDateAdd(temporalDate.[[Calendar]], temporalDate,
|
||||
// negatedDuration, options).
|
||||
return CalendarDateAdd(isolate, handle(temporal_date->calendar(), isolate),
|
||||
temporal_date, negated_duration, options,
|
||||
isolate->factory()->undefined_value());
|
||||
}
|
||||
|
||||
// #sec-temporal.now.plaindate
|
||||
MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Now(
|
||||
Isolate* isolate, Handle<Object> calendar_like,
|
||||
|
@ -290,6 +290,16 @@ class JSTemporalPlainDate
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> From(
|
||||
Isolate* isolate, Handle<Object> item, Handle<Object> options);
|
||||
|
||||
// #sec-temporal.plaindate.prototype.add
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> Add(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date,
|
||||
Handle<Object> temporal_duration_like, Handle<Object> options);
|
||||
|
||||
// #sec-temporal.plaindate.prototype.subtract
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> Subtract(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date,
|
||||
Handle<Object> temporal_duration_like, Handle<Object> options);
|
||||
|
||||
// #sec-temporal.plaindate.prototype.getisofields
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date);
|
||||
|
@ -59,7 +59,6 @@
|
||||
'temporal/instant-subtract': [FAIL],
|
||||
'temporal/instant-to-json': [FAIL],
|
||||
'temporal/instant-toJSON': [FAIL],
|
||||
'temporal/plain-date-add': [FAIL],
|
||||
'temporal/plain-date-time-add': [FAIL],
|
||||
'temporal/plain-date-time-subtract': [FAIL],
|
||||
'temporal/plain-date-time-to-json': [FAIL],
|
||||
|
@ -298,7 +298,6 @@
|
||||
'built-ins/RegExp/property-escapes/generated/strings/RGI_Emoji_ZWJ_Sequence': [FAIL],
|
||||
|
||||
# -0
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/balance-smaller-units': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/roundingmode-undefined': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/smallestunit-wrong-type': [FAIL],
|
||||
'built-ins/Temporal/Duration/prototype/add/argument-string-negative-fractional-units': [FAIL],
|
||||
@ -669,22 +668,7 @@
|
||||
'built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/from/limits': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/limits': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/argument-not-object': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/argument-string': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/argument-string-negative-fractional-units': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/balance-smaller-units': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/branding': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/infinity-throws-rangeerror': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/limits': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/negative-infinity-throws-rangeerror': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/non-integer-throws-rangeerror': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/options-invalid': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/options-undefined': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/order-of-operations': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/overflow-invalid-string': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/overflow-undefined': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/overflow-wrong-type': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/subclassing-ignored': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/argument-plaindatetime': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/argument-string-with-utc-designator': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
|
||||
@ -718,21 +702,7 @@
|
||||
'built-ins/Temporal/PlainDate/prototype/since/smallestunit-invalid-string': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/smallestunit-plurals-accepted': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/smallestunit-undefined': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/argument-not-object': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/argument-string': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/argument-string-negative-fractional-units': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/branding': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/infinity-throws-rangeerror': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/limits': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/negative-infinity-throws-rangeerror': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/non-integer-throws-rangeerror': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/options-invalid': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/options-undefined': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/overflow-invalid-string': [FAIL],
|
||||
'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-zoneddatetime-balance-negative-time-units': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/basic': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/toZonedDateTime/basic': [FAIL],
|
||||
@ -1555,13 +1525,6 @@
|
||||
'built-ins/Temporal/Instant/prototype/subtract/argument-string-fractional-units-rounding-mode': [FAIL],
|
||||
'built-ins/Temporal/Instant/prototype/until/largestunit-smallestunit-mismatch': [FAIL],
|
||||
'built-ins/Temporal/Instant/prototype/until/year-zero': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/argument-invalid-duration': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/argument-missing-properties': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/argument-singular-units': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/balance-smaller-units-basic': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/basic': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/overflow-constrain': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/overflow-reject': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/days-in-month': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/days-in-year': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/largestunit-undefined': [FAIL],
|
||||
@ -1574,13 +1537,6 @@
|
||||
'built-ins/Temporal/PlainDate/prototype/since/smallestunit-higher-units': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/weeks-months': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/year-zero': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/argument-invalid-duration': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/argument-missing-properties': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/argument-singular-units': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/balance-smaller-units-basic': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/basic': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/overflow-constrain': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/overflow-reject': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-no-implicit-midnight': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-time-designator-required-for-disambiguation': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-with-time-designator': [FAIL],
|
||||
@ -1834,9 +1790,7 @@
|
||||
'built-ins/Temporal/Instant/prototype/toString/roundingmode-trunc': [FAIL],
|
||||
'built-ins/Temporal/Instant/prototype/toString/smallestunit-fractionalseconddigits': [FAIL],
|
||||
'built-ins/Temporal/Instant/prototype/until/options-wrong-type': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/add/options-wrong-type': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/since/options-wrong-type': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/subtract/options-wrong-type': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/until/options-wrong-type': [FAIL],
|
||||
'built-ins/Temporal/PlainDateTime/prototype/add/options-wrong-type': [FAIL],
|
||||
'built-ins/Temporal/PlainDateTime/prototype/round/balance': [FAIL],
|
||||
|
Loading…
Reference in New Issue
Block a user