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

[Temporal] Add Temporal.Calendar.prototype.day

Spec Text:
https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.day

Note- this is only the non-intl version. intl version in
https://tc39.es/proposal-temporal/#sup-temporal.calendar.prototype.day
will be implemented in later cl.

Bug: v8:11544
Change-Id: If56182cf65b3b8cc91ed843f0e20edeb6a065954
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3531556Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80347}
parent e86bde3d
......@@ -304,8 +304,6 @@ TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDateAdd)
TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMonth)
/* Temporal #sec-temporal.calendar.prototype.monthcode */
TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMonthCode)
/* Temporal #sec-temporal.calendar.prototype.day */
TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDay)
/* Temporal #sec-temporal.calendar.prototype.weekofyear */
TO_BE_IMPLEMENTED(TemporalCalendarPrototypeWeekOfYear)
/* Temporal #sec-temporal.calendar.prototype.tojson */
......@@ -793,6 +791,7 @@ TEMPORAL_CONSTRUCTOR1(Calendar)
TEMPORAL_ID_BY_TO_STRING(Calendar)
TEMPORAL_PROTOTYPE_METHOD2(Calendar, DateFromFields, dateFromFields)
TEMPORAL_PROTOTYPE_METHOD3(Calendar, DateUntil, dateUntil)
TEMPORAL_PROTOTYPE_METHOD1(Calendar, Day, day)
TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInMonth, daysInMonth)
TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInWeek, daysInWeek)
TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInYear, daysInYear)
......
......@@ -6186,6 +6186,44 @@ MaybeHandle<JSTemporalDuration> JSTemporalCalendar::DateUntil(
{result.days, 0, 0, 0, 0, 0, 0}});
}
// #sec-temporal.calendar.prototype.day
MaybeHandle<Smi> JSTemporalCalendar::Day(Isolate* isolate,
Handle<JSTemporalCalendar> calendar,
Handle<Object> temporal_date_like) {
// 1. Let calendar be the this value.
// 2. Perform ? RequireInternalSlot(calendar,
// [[InitializedTemporalCalendar]]).
// 3. Assert: calendar.[[Identifier]] is "iso8601".
// 4. If Type(temporalDateLike) is not Object or temporalDateLike does not
// have an [[InitializedTemporalDate]] or [[InitializedTemporalMonthDay]]
// internal slot, then
if (!(temporal_date_like->IsJSTemporalPlainDate() ||
temporal_date_like->IsJSTemporalPlainDateTime() ||
temporal_date_like->IsJSTemporalPlainMonthDay())) {
// a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike).
ASSIGN_RETURN_ON_EXCEPTION(
isolate, temporal_date_like,
ToTemporalDate(isolate, temporal_date_like,
isolate->factory()->NewJSObjectWithNullProto(),
"Temporal.Calendar.prototype.day"),
Smi);
}
// 5. Let day be ! ISODay(temporalDateLike).
int32_t day;
if (temporal_date_like->IsJSTemporalPlainDate()) {
day = Handle<JSTemporalPlainDate>::cast(temporal_date_like)->iso_day();
} else if (temporal_date_like->IsJSTemporalPlainDateTime()) {
day = Handle<JSTemporalPlainDateTime>::cast(temporal_date_like)->iso_day();
} else {
DCHECK(temporal_date_like->IsJSTemporalPlainMonthDay());
day = Handle<JSTemporalPlainMonthDay>::cast(temporal_date_like)->iso_day();
}
// 6. Return 𝔽(day).
return handle(Smi::FromInt(day), isolate);
}
// #sec-temporal.calendar.prototype.tostring
MaybeHandle<String> JSTemporalCalendar::ToString(
Isolate* isolate, Handle<JSTemporalCalendar> calendar,
......
......@@ -107,6 +107,11 @@ class JSTemporalCalendar
Isolate* isolate, Handle<JSTemporalCalendar> calendar, Handle<Object> one,
Handle<Object> two, Handle<Object> options);
// #sec-temporal.calendar.prototype.day
V8_WARN_UNUSED_RESULT static MaybeHandle<Smi> Day(
Isolate* isolate, Handle<JSTemporalCalendar> calendar,
Handle<Object> temporal_date_like);
// #sec-temporal.calendar.prototype.tostring
static MaybeHandle<String> ToString(Isolate* isolate,
Handle<JSTemporalCalendar> calendar,
......
......@@ -48,7 +48,6 @@
'temporal/calendar-date-add': [FAIL],
'temporal/calendar-date-from-fields': [FAIL],
'temporal/calendar-date-until': [FAIL],
'temporal/calendar-day': [FAIL],
'temporal/calendar-month': [FAIL],
'temporal/calendar-month-code': [FAIL],
'temporal/calendar-month-day-from-fields': [FAIL],
......
......@@ -474,22 +474,7 @@
'built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-month-day': [FAIL],
'built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-month-day-need-constrain': [FAIL],
'built-ins/Temporal/Calendar/prototype/dateUntil/argument-plaindatetime': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-string-with-utc-designator': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/basic': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/branding': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/calendar-fields-iterable': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/calendar-temporal-object': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/date': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/date-time': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/infinity-throws-rangeerror': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/month-day': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInYear/basic': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/string': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/throw-range-error-ToTemporalDate': [FAIL],
'built-ins/Temporal/Calendar/prototype/month/argument-string-with-utc-designator': [FAIL],
'built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
......@@ -1302,7 +1287,6 @@
'built-ins/Temporal/PlainMonthDay/from/overflow-undefined': [FAIL],
'built-ins/Temporal/PlainMonthDay/from/overflow-wrong-type': [FAIL],
'built-ins/Temporal/PlainMonthDay/from/subclassing-ignored': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/day/basic': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-with-utc-designator': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/equals/argument-wrong-type': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/equals/basic': [FAIL],
......@@ -2157,7 +2141,6 @@
'intl402/DateTimeFormat/prototype/formatToParts/temporal-objects-resolved-time-zone': [FAIL],
'intl402/Temporal/Calendar/prototype/dateAdd/date-infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/Calendar/prototype/dateFromFields/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/Calendar/prototype/day/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/Calendar/prototype/era/argument-string-with-utc-designator': [FAIL],
'intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'intl402/Temporal/Calendar/prototype/era/branding': [FAIL],
......@@ -2584,7 +2567,6 @@
'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-invalid': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-string-invalid': [FAIL],
'built-ins/Temporal/Calendar/prototype/month/argument-string-invalid': [FAIL],
'built-ins/Temporal/Calendar/prototype/monthCode/argument-string-invalid': [FAIL],
'built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-invalid': [FAIL],
......@@ -2837,10 +2819,9 @@
'built-ins/Temporal/Calendar/prototype/dateAdd/argument-wrong-type': [FAIL],
'built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-number': [FAIL],
'built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-wrong-type': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-number': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-number': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-wrong-type': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-wrong-type': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/basic': [FAIL],
'built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-number': [FAIL],
'built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-wrong-type': [FAIL],
'built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-number': [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