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

[Temporal] Add PlainDate.prototype.toJSON

Also add AOs: PadISOYear, FormatCalendarAnnotation, TemporalDateToString
Spec Text:
https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.tojson
https://tc39.es/proposal-temporal/#sec-temporal-padisoyear
https://tc39.es/proposal-temporal/#sec-temporal-formatcalendarannotation
https://tc39.es/proposal-temporal/#sec-temporal-temporaldatetostring

Change the ISODateTimeWithinLimits from
-8.64 × 10^21 - 8.64 × 10^16, 8.64 × 10^21 + 8.64 × 10^16
to
-8.64 × 10^21 - 8.64 × 10^13, 8.64 × 10^21 + 8.64 × 10^13
per https://github.com/tc39/proposal-temporal/pull/1723

Change to use AppendCStringLiteral instead of AppendCharacter when
appropriate.

Bug: v8:11544
Change-Id: I01f22657b2c3e5aacbea790593d7e9f60076ec74
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3438379
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80622}
parent 0236d7b5
......@@ -62,8 +62,6 @@ TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainDateTime)
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToZonedDateTime)
/* Temporal #sec-temporal.plaindate.prototype.tostring */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToString)
/* Temporal #sec-temporal.plaindate.prototype.tojson */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToJSON)
/* Temporal.PlaneTime */
/* Temporal #sec-temporal.plaintime.compare */
......@@ -496,6 +494,7 @@ TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, InLeapYear, inLeapYear)
TEMPORAL_PROTOTYPE_METHOD1(PlainDate, WithCalendar, withCalendar)
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, GetISOFields, getISOFields)
TEMPORAL_VALUE_OF(PlainDate)
TEMPORAL_PROTOTYPE_METHOD0(PlainDate, ToJSON, toJSON)
// PlainTime
BUILTIN(TemporalPlainTimeConstructor) {
......
This diff is collapsed.
......@@ -262,6 +262,11 @@ class JSTemporalPlainDate
// #sec-temporal.now.plaindateiso
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like);
// #sec-temporal.plaindate.prototype.tojson
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToJSON(
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date);
DECL_PRINTER(JSTemporalPlainDate)
DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY()
......
......@@ -45,8 +45,6 @@
##############################################################################
# Temporal tests to be implemented
# https://crbug.com/v8/11544
'temporal/calendar-date-add': [FAIL],
'temporal/calendar-date-from-fields': [FAIL],
'temporal/calendar-date-until': [FAIL],
'temporal/calendar-month-day-from-fields': [FAIL],
'temporal/calendar-week-of-year': [FAIL],
......@@ -80,7 +78,6 @@
'temporal/plain-date-time-with': [FAIL],
'temporal/plain-date-time-with-plain-date': [FAIL],
'temporal/plain-date-time-with-plain-time': [FAIL],
'temporal/plain-date-to-json': [FAIL],
'temporal/plain-date-to-plain-date-time': [FAIL],
'temporal/plain-date-to-plain-month-day': [FAIL],
'temporal/plain-date-to-plain-year-month': [FAIL],
......
......@@ -7,12 +7,12 @@
assertEquals("2021-07-01", (new Temporal.PlainDate(2021, 7, 1)).toJSON());
assertEquals("9999-12-31", (new Temporal.PlainDate(9999, 12, 31)).toJSON());
assertEquals("1000-01-01", (new Temporal.PlainDate(1000, 1, 1)).toJSON());
assertEquals("0099-08-01", (new Temporal.PlainDate(99, 8, 1)).toJSON());
assertEquals("0999-12-31", (new Temporal.PlainDate(999, 12, 31)).toJSON());
// years out of 4 digits range
assertEquals("+010000-01-01", (new Temporal.PlainDate(10000, 1, 1)).toJSON());
assertEquals("+025021-07-01", (new Temporal.PlainDate(25021, 7, 1)).toJSON());
assertEquals("+000999-12-31", (new Temporal.PlainDate(999, 12, 31)).toJSON());
assertEquals("+000099-08-01", (new Temporal.PlainDate(99, 8, 1)).toJSON());
assertEquals("-000020-09-30", (new Temporal.PlainDate(-20, 9, 30)).toJSON());
assertEquals("-002021-07-01", (new Temporal.PlainDate(-2021, 7, 1)).toJSON());
assertEquals("-022021-07-01", (new Temporal.PlainDate(-22021, 7, 1)).toJSON());
......@@ -795,8 +795,6 @@
'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/toJSON/branding': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toJSON/year-format': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toLocaleString/branding': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toLocaleString/return-string': [FAIL],
'built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-with-utc-designator': [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