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

[Temporal] Add Calendar.prototype.daysInWeek

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

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

Bug: v8:11544
Change-Id: If54733ae7c902b4d189fc22b0800942f8748981c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3439186Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79721}
parent 63f9f0fa
...@@ -320,8 +320,6 @@ TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMonthCode) ...@@ -320,8 +320,6 @@ TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMonthCode)
TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDay) TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDay)
/* Temporal #sec-temporal.calendar.prototype.weekofyear */ /* Temporal #sec-temporal.calendar.prototype.weekofyear */
TO_BE_IMPLEMENTED(TemporalCalendarPrototypeWeekOfYear) TO_BE_IMPLEMENTED(TemporalCalendarPrototypeWeekOfYear)
/* Temporal #sec-temporal.calendar.prototype.daysinweek */
TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDaysInWeek)
/* Temporal #sec-temporal.calendar.prototype.mergefields */ /* Temporal #sec-temporal.calendar.prototype.mergefields */
TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMergeFields) TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMergeFields)
/* Temporal #sec-temporal.calendar.prototype.tojson */ /* Temporal #sec-temporal.calendar.prototype.tojson */
...@@ -789,6 +787,7 @@ TEMPORAL_GET_BIGINT_AFTER_DIVID(Instant, EpochMicroseconds, nanoseconds, 1000, ...@@ -789,6 +787,7 @@ TEMPORAL_GET_BIGINT_AFTER_DIVID(Instant, EpochMicroseconds, nanoseconds, 1000,
TEMPORAL_CONSTRUCTOR1(Calendar) TEMPORAL_CONSTRUCTOR1(Calendar)
TEMPORAL_ID_BY_TO_STRING(Calendar) TEMPORAL_ID_BY_TO_STRING(Calendar)
TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInMonth, daysInMonth) TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInMonth, daysInMonth)
TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInWeek, daysInWeek)
TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInYear, daysInYear) TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInYear, daysInYear)
TEMPORAL_PROTOTYPE_METHOD1(Calendar, DayOfWeek, dayOfWeek) TEMPORAL_PROTOTYPE_METHOD1(Calendar, DayOfWeek, dayOfWeek)
TEMPORAL_PROTOTYPE_METHOD1(Calendar, DayOfYear, dayOfYear) TEMPORAL_PROTOTYPE_METHOD1(Calendar, DayOfYear, dayOfYear)
......
...@@ -5089,6 +5089,26 @@ MaybeHandle<Oddball> JSTemporalCalendar::InLeapYear( ...@@ -5089,6 +5089,26 @@ MaybeHandle<Oddball> JSTemporalCalendar::InLeapYear(
return isolate->factory()->ToBoolean(IsISOLeapYear(isolate, year)); return isolate->factory()->ToBoolean(IsISOLeapYear(isolate, year));
} }
// #sec-temporal.calendar.prototype.daysinweek
MaybeHandle<Smi> JSTemporalCalendar::DaysInWeek(
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. Perform ? ToTemporalDate(temporalDateLike).
Handle<JSTemporalPlainDate> date;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, date,
ToTemporalDate(isolate, temporal_date_like,
isolate->factory()->NewJSObjectWithNullProto(),
"Temporal.Calendar.prototype.daysInWeek"),
Smi);
// 5. Return 7𝔽.
return handle(Smi::FromInt(7), isolate);
}
// #sec-temporal.calendar.prototype.tostring // #sec-temporal.calendar.prototype.tostring
MaybeHandle<String> JSTemporalCalendar::ToString( MaybeHandle<String> JSTemporalCalendar::ToString(
Isolate* isolate, Handle<JSTemporalCalendar> calendar, Isolate* isolate, Handle<JSTemporalCalendar> calendar,
......
...@@ -87,6 +87,11 @@ class JSTemporalCalendar ...@@ -87,6 +87,11 @@ class JSTemporalCalendar
Isolate* isolate, Handle<JSTemporalCalendar> calendar, Isolate* isolate, Handle<JSTemporalCalendar> calendar,
Handle<Object> temporal_date_like); Handle<Object> temporal_date_like);
// #sec-temporal.calendar.prototype.daysinweek
V8_WARN_UNUSED_RESULT static MaybeHandle<Smi> DaysInWeek(
Isolate* isolate, Handle<JSTemporalCalendar> calendar,
Handle<Object> temporal_date_like);
// #sec-temporal.calendar.prototype.tostring // #sec-temporal.calendar.prototype.tostring
static MaybeHandle<String> ToString(Isolate* isolate, static MaybeHandle<String> ToString(Isolate* isolate,
Handle<JSTemporalCalendar> calendar, Handle<JSTemporalCalendar> calendar,
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
'temporal/calendar-date-from-fields': [FAIL], 'temporal/calendar-date-from-fields': [FAIL],
'temporal/calendar-date-until': [FAIL], 'temporal/calendar-date-until': [FAIL],
'temporal/calendar-day': [FAIL], 'temporal/calendar-day': [FAIL],
'temporal/calendar-days-in-week': [FAIL],
'temporal/calendar-fields': [FAIL], 'temporal/calendar-fields': [FAIL],
'temporal/calendar-merge-fields': [FAIL], 'temporal/calendar-merge-fields': [FAIL],
'temporal/calendar-month': [FAIL], 'temporal/calendar-month': [FAIL],
......
...@@ -500,20 +500,10 @@ ...@@ -500,20 +500,10 @@
'built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-fields-iterable': [FAIL], 'built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-fields-iterable': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-temporal-object': [FAIL], 'built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-temporal-object': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInMonth/infinity-throws-rangeerror': [FAIL], 'built-ins/Temporal/Calendar/prototype/daysInMonth/infinity-throws-rangeerror': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-with-utc-designator': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/basic': [FAIL], 'built-ins/Temporal/Calendar/prototype/daysInWeek/basic': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/branding': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-fields-iterable': [FAIL], 'built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-fields-iterable': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-temporal-object': [FAIL], 'built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-temporal-object': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/date': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/date-time': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/infinity-throws-rangeerror': [FAIL], 'built-ins/Temporal/Calendar/prototype/daysInWeek/infinity-throws-rangeerror': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/string': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/throw-range-error-ToTemporalDate': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInYear/basic': [FAIL], 'built-ins/Temporal/Calendar/prototype/daysInYear/basic': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInYear/calendar-fields-iterable': [FAIL], 'built-ins/Temporal/Calendar/prototype/daysInYear/calendar-fields-iterable': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInYear/calendar-temporal-object': [FAIL], 'built-ins/Temporal/Calendar/prototype/daysInYear/calendar-temporal-object': [FAIL],
...@@ -933,7 +923,6 @@ ...@@ -933,7 +923,6 @@
'built-ins/Temporal/PlainDate/prototype/add/subclassing-ignored': [FAIL], 'built-ins/Temporal/PlainDate/prototype/add/subclassing-ignored': [FAIL],
'built-ins/Temporal/PlainDate/prototype/dayOfWeek/basic': [FAIL], 'built-ins/Temporal/PlainDate/prototype/dayOfWeek/basic': [FAIL],
'built-ins/Temporal/PlainDate/prototype/dayOfYear/basic': [FAIL], 'built-ins/Temporal/PlainDate/prototype/dayOfYear/basic': [FAIL],
'built-ins/Temporal/PlainDate/prototype/daysInWeek/basic': [FAIL],
'built-ins/Temporal/PlainDate/prototype/equals/argument-object-invalid': [FAIL], 'built-ins/Temporal/PlainDate/prototype/equals/argument-object-invalid': [FAIL],
'built-ins/Temporal/PlainDate/prototype/equals/argument-object-valid': [FAIL], 'built-ins/Temporal/PlainDate/prototype/equals/argument-object-valid': [FAIL],
'built-ins/Temporal/PlainDate/prototype/equals/argument-plaindatetime': [FAIL], 'built-ins/Temporal/PlainDate/prototype/equals/argument-plaindatetime': [FAIL],
...@@ -2648,7 +2637,6 @@ ...@@ -2648,7 +2637,6 @@
'built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-invalid': [FAIL], 'built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-invalid': [FAIL],
'built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-invalid': [FAIL], 'built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-invalid': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/argument-string-invalid': [FAIL], 'built-ins/Temporal/Calendar/prototype/day/argument-string-invalid': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-invalid': [FAIL],
'built-ins/Temporal/Calendar/prototype/month/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/monthCode/argument-string-invalid': [FAIL],
'built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-invalid': [FAIL], 'built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-invalid': [FAIL],
...@@ -2697,7 +2685,6 @@ ...@@ -2697,7 +2685,6 @@
'built-ins/Temporal/PlainDateTime/prototype/add/negative-duration': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/add/negative-duration': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/add/options-empty': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/add/options-empty': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/add/options-invalid': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/add/options-invalid': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/daysInWeek/basic': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/equals/argument-object-insufficient-data': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/equals/argument-object-insufficient-data': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/equals/basic': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/equals/basic': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/equals/cast': [FAIL], 'built-ins/Temporal/PlainDateTime/prototype/equals/cast': [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