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

[Temporal] Add non-intl toLocaleString to Duration

Spec Text:
https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.tolocalestring

This does NOT implement the intl version of toLocale in (noteice 'sup'
vs 'sec' after #)
https://tc39.es/proposal-temporal/#sup-temporal.duration.prototype.tolocalestring
since the details is not specified yet.

Bug: v8:11544
Change-Id: I7f5a2e9766005d1a7f6409d428ca53b5a38a3960
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3696482Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81167}
parent 1e0d18dc
......@@ -88,8 +88,6 @@ TO_BE_IMPLEMENTED(TemporalDurationPrototypeSubtract)
TO_BE_IMPLEMENTED(TemporalDurationPrototypeRound)
/* Temporal #sec-temporal.duration.prototype.total */
TO_BE_IMPLEMENTED(TemporalDurationPrototypeTotal)
/* Temporal #sec-temporal.duration.prototype.tolocalestring */
TO_BE_IMPLEMENTED(TemporalDurationPrototypeToLocaleString)
/* Temporal #sec-temporal.duration.prototype.tostring */
TO_BE_IMPLEMENTED(TemporalDurationPrototypeToString)
......@@ -626,6 +624,7 @@ TEMPORAL_PROTOTYPE_METHOD0(Duration, Negated, negated)
TEMPORAL_PROTOTYPE_METHOD0(Duration, Abs, abs)
TEMPORAL_VALUE_OF(Duration)
TEMPORAL_PROTOTYPE_METHOD0(Duration, ToJSON, toJSON)
TEMPORAL_PROTOTYPE_METHOD2(Duration, ToLocaleString, toLocaleString)
// Instant
TEMPORAL_CONSTRUCTOR1(Instant)
......
......@@ -6262,6 +6262,23 @@ MaybeHandle<String> JSTemporalDuration::ToJSON(
return TemporalDurationToString(isolate, duration, Precision::kAuto);
}
// #sec-temporal.duration.prototype.tolocalestring
MaybeHandle<String> JSTemporalDuration::ToLocaleString(
Isolate* isolate, Handle<JSTemporalDuration> duration,
Handle<Object> locales, Handle<Object> options) {
// 1. Let duration be the this value.
// 2. Perform ? RequireInternalSlot(duration,
// [[InitializedTemporalDuration]]).
// 3. Return ! TemporalDurationToString(duration.[[Years]],
// duration.[[Months]], duration.[[Weeks]], duration.[[Days]],
// duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]],
// duration.[[Milliseconds]], duration.[[Microseconds]],
// duration.[[Nanoseconds]], "auto").
// TODO(ftang) Implement #sup-temporal.duration.prototype.tolocalestring
return TemporalDurationToString(isolate, duration, Precision::kAuto);
}
// #sec-temporal.calendar
MaybeHandle<JSTemporalCalendar> JSTemporalCalendar::Constructor(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
......
......@@ -197,6 +197,11 @@ class JSTemporalDuration
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToJSON(
Isolate* isolate, Handle<JSTemporalDuration> duration);
// #sec-temporal.duration.prototype.tolocalestring
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToLocaleString(
Isolate* isolate, Handle<JSTemporalDuration> duration,
Handle<Object> locales, Handle<Object> options);
// #sec-temporal.duration.prototype.with
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalDuration> With(
Isolate* isolate, Handle<JSTemporalDuration> duration,
......
......@@ -497,7 +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/toLocaleString/branding': [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],
......
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