[Temporal] Add toString to Duration

Add AOs: MoveRelativeZonedDateTime,  DaysUntil, MoveRelativeDate,
RoundDuration,

Also fix bugs in CalendarDateAdd, TemporalDurationToString, IsValidDuration

Spec Text:
https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.tostring
https://tc39.es/proposal-temporal/#sec-temporal-moverelativezoneddatetime
https://tc39.es/proposal-temporal/#sec-temporal-daysuntil
https://tc39.es/proposal-temporal/#sec-temporal-moverelativedate
https://tc39.es/proposal-temporal/#sec-temporal-roundduration

Bug: v8:11544
Change-Id: I351cdb88a930f3f7b48f351549d390e5bd02d91e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3715381
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81501}
This commit is contained in:
Frank Tang 2022-06-29 15:58:48 -07:00 committed by V8 LUCI CQ
parent fb8cd26f27
commit a63e2ddfb4
5 changed files with 998 additions and 301 deletions

View File

@ -80,8 +80,6 @@ TO_BE_IMPLEMENTED(TemporalDurationPrototypeSubtract)
TO_BE_IMPLEMENTED(TemporalDurationPrototypeRound)
/* Temporal #sec-temporal.duration.prototype.total */
TO_BE_IMPLEMENTED(TemporalDurationPrototypeTotal)
/* Temporal #sec-temporal.duration.prototype.tostring */
TO_BE_IMPLEMENTED(TemporalDurationPrototypeToString)
/* Temporal.Instant */
/* Temporal #sec-temporal.instant.prototype.until */
@ -611,6 +609,7 @@ TEMPORAL_PROTOTYPE_METHOD0(Duration, Abs, abs)
TEMPORAL_VALUE_OF(Duration)
TEMPORAL_PROTOTYPE_METHOD0(Duration, ToJSON, toJSON)
TEMPORAL_PROTOTYPE_METHOD2(Duration, ToLocaleString, toLocaleString)
TEMPORAL_PROTOTYPE_METHOD1(Duration, ToString, toString)
// Instant
TEMPORAL_CONSTRUCTOR1(Instant)

File diff suppressed because it is too large Load Diff

View File

@ -202,6 +202,11 @@ class JSTemporalDuration
Isolate* isolate, Handle<JSTemporalDuration> duration,
Handle<Object> locales, Handle<Object> options);
// #sec-temporal.duration.prototype.tostring
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToString(
Isolate* isolate, Handle<JSTemporalDuration> duration,
Handle<Object> options);
// #sec-temporal.duration.prototype.with
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalDuration> With(
Isolate* isolate, Handle<JSTemporalDuration> duration,

View File

@ -47,7 +47,6 @@
# https://crbug.com/v8/11544
'temporal/calendar-week-of-year': [FAIL],
'temporal/duration-add': [FAIL],
'temporal/duration-to-json': [FAIL],
'temporal/instant-constructor': [FAIL],
'temporal/instant-from-epoch-milliseconds': [FAIL],
'temporal/instant-from-epoch-seconds': [FAIL],

View File

@ -497,25 +497,6 @@
'built-ins/Temporal/Duration/prototype/subtract/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/Duration/prototype/subtract/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/Duration/prototype/subtract/subclassing-ignored': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/blank-duration-precision': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/branding': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/fractionalseconddigits-invalid-string': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/fractionalseconddigits-nan': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/fractionalseconddigits-non-integer': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/fractionalseconddigits-out-of-range': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/fractionalseconddigits-undefined': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/fractionalseconddigits-wrong-type': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/negative-components': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/options-undefined': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/precision': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/roundingmode-invalid-string': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/roundingmode-undefined': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/roundingmode-wrong-type': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/smallestunit-invalid-string': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/smallestunit-plurals-accepted': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/smallestunit-undefined': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/smallestunit-valid-units': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/smallestunit-wrong-type': [FAIL],
'built-ins/Temporal/Duration/prototype/total/balance-negative-result': [FAIL],
'built-ins/Temporal/Duration/prototype/total/branding': [FAIL],
'built-ins/Temporal/Duration/prototype/total/calendar-dateadd-called-with-plaindate-instance': [FAIL],
@ -1197,7 +1178,6 @@
'built-ins/Temporal/Duration/prototype/round/year-zero': [FAIL],
'built-ins/Temporal/Duration/prototype/subtract/argument-string-fractional-units-rounding-mode': [FAIL],
'built-ins/Temporal/Duration/prototype/subtract/year-zero': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/fractionalseconddigits-exact-number-of-digits': [FAIL],
'built-ins/Temporal/Duration/prototype/total/calendar-possibly-required': [FAIL],
'built-ins/Temporal/Duration/prototype/total/year-zero': [FAIL],
'built-ins/Temporal/Instant/prototype/since/largestunit-smallestunit-mismatch': [FAIL],
@ -1346,8 +1326,6 @@
'built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-invalid': [FAIL],
'built-ins/Temporal/Duration/compare/twenty-five-hour-day': [FAIL],
'built-ins/Temporal/Duration/prototype/toJSON/basic': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/balance': [FAIL],
'built-ins/Temporal/PlainDate/prototype/since/argument-string-invalid': [FAIL],
'built-ins/Temporal/PlainDate/prototype/until/argument-string-invalid': [FAIL],
'built-ins/Temporal/PlainDateTime/datetime-math': [FAIL],
@ -1370,14 +1348,6 @@
'built-ins/Temporal/Duration/prototype/round/options-wrong-type': [FAIL],
'built-ins/Temporal/Duration/prototype/round/roundto-invalid-string': [FAIL],
'built-ins/Temporal/Duration/prototype/subtract/options-wrong-type': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/fractionalseconddigits-auto': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/fractionalseconddigits-number': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/options-wrong-type': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/roundingmode-ceil': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/roundingmode-floor': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/roundingmode-halfExpand': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/roundingmode-trunc': [FAIL],
'built-ins/Temporal/Duration/prototype/toString/smallestunit-fractionalseconddigits': [FAIL],
'built-ins/Temporal/Instant/prototype/round/rounding-direction': [FAIL],
'built-ins/Temporal/Instant/prototype/since/options-wrong-type': [FAIL],
'built-ins/Temporal/Instant/prototype/toString/fractionalseconddigits-number': [FAIL],