Implement Temporal.Instant.prototype.toLocaleString

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
Seonghyun Kim 2025-11-27 13:56:40 +09:00 committed by Patrick Kim
commit 75cdb470ba
3 changed files with 8 additions and 10 deletions

View file

@ -331,7 +331,11 @@ static Value builtinTemporalInstantToJSON(ExecutionState& state, Value thisValue
static Value builtinTemporalInstantToLocaleString(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
{
RESOLVE_THIS_BINDING_TO_INSTANT2(instant, toLocaleString);
return instant->toString(state, Value());
Value locales = argc > 0 ? argv[0] : Value();
Value options = argc > 1 ? argv[1] : Value();
auto dateFormat = new IntlDateTimeFormatObject(state, locales, options);
auto result = dateFormat->format(state, instant);
return new UTF16String(result.data(), result.length());
}
static Value builtinTemporalInstantToString(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)

View file

@ -1248,6 +1248,9 @@ UTF16StringDataNonGCStd IntlDateTimeFormatObject::format(ExecutionState& state,
options->directDefineOwnProperty(state, state.context()->staticStrings().lazyHour(), ObjectPropertyDescriptor(numeric));
options->directDefineOwnProperty(state, state.context()->staticStrings().lazyMinute(), ObjectPropertyDescriptor(numeric));
options->directDefineOwnProperty(state, state.context()->staticStrings().lazySecond(), ObjectPropertyDescriptor(numeric));
if (!m_timeZoneName.isUndefined()) {
options->directDefineOwnProperty(state, state.context()->staticStrings().lazyTimeZoneName(), ObjectPropertyDescriptor(m_timeZoneName));
}
} else if (dateTimeValue.second.value() == TemporalKind::ZonedDateTime) {
options->directDefineOwnProperty(state, state.context()->staticStrings().lazyYear(), ObjectPropertyDescriptor(numeric));
options->directDefineOwnProperty(state, state.context()->staticStrings().lazyMonth(), ObjectPropertyDescriptor(numeric));

View file

@ -178,7 +178,6 @@
<test id="harness/asyncHelpers-asyncTest-without-async-flag"><reason>TODO</reason></test>
<test id="harness/asyncHelpers-throwsAsync-func-never-settles"><reason>TODO</reason></test>
<test id="intl402/DateTimeFormat/prototype/format/temporal-objects-not-overlapping-options"><reason>TODO</reason></test>
<test id="intl402/DateTimeFormat/prototype/format/temporal-objects-resolved-time-zone"><reason>TODO</reason></test>
<test id="intl402/DateTimeFormat/prototype/format/temporal-plaindate-formatting-datetime-style"><reason>TODO</reason></test>
<test id="intl402/DateTimeFormat/prototype/format/temporal-plaindatetime-formatting-datetime-style"><reason>TODO</reason></test>
<test id="intl402/DateTimeFormat/prototype/format/temporal-plainmonthday-formatting-datetime-style"><reason>TODO</reason></test>
@ -236,13 +235,6 @@
<test id="intl402/Temporal/Duration/prototype/total/dst-day-length"><reason>TODO</reason></test>
<test id="intl402/Temporal/Duration/prototype/total/dst-rounding-result"><reason>TODO</reason></test>
<test id="intl402/Temporal/Duration/prototype/total/relativeto-sub-minute-offset"><reason>TODO</reason></test>
<test id="intl402/Temporal/Instant/prototype/toLocaleString/dateStyle"><reason>TODO</reason></test>
<test id="intl402/Temporal/Instant/prototype/toLocaleString/dateStyle-timeStyle-undefined"><reason>TODO</reason></test>
<test id="intl402/Temporal/Instant/prototype/toLocaleString/default-includes-time-not-time-zone-name"><reason>TODO</reason></test>
<test id="intl402/Temporal/Instant/prototype/toLocaleString/locales-undefined"><reason>TODO</reason></test>
<test id="intl402/Temporal/Instant/prototype/toLocaleString/lone-options-accepted"><reason>TODO</reason></test>
<test id="intl402/Temporal/Instant/prototype/toLocaleString/options-conflict"><reason>TODO</reason></test>
<test id="intl402/Temporal/Instant/prototype/toLocaleString/options-undefined"><reason>TODO</reason></test>
<test id="intl402/Temporal/PlainDate/prototype/toLocaleString/calendar-mismatch"><reason>TODO</reason></test>
<test id="intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle"><reason>TODO</reason></test>
<test id="intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle-timeStyle-undefined"><reason>TODO</reason></test>
@ -898,7 +890,6 @@
<test id="staging/Intl402/Temporal/old/duration-total"><reason>TODO</reason></test>
<test id="staging/Intl402/Temporal/old/hebrew-leap-months"><reason>TODO</reason></test>
<test id="staging/Intl402/Temporal/old/indian-calendar"><reason>TODO</reason></test>
<test id="staging/Intl402/Temporal/old/instant-toLocaleString"><reason>TODO</reason></test>
<test id="staging/Intl402/Temporal/old/islamic-calendars-islamic"><reason>TODO</reason></test>
<test id="staging/Intl402/Temporal/old/islamic-calendars-islamic-civil"><reason>TODO</reason></test>
<test id="staging/Intl402/Temporal/old/islamic-calendars-islamic-rgsa"><reason>TODO</reason></test>