[Temporal] Add Temporal.*.prototype.withCalendar
Bug: v8:11544 Change-Id: I59e5a448385b2e67927c18c9609f24f4d66f3756 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3380305 Reviewed-by: Shu-yu Guo <syg@chromium.org> Commit-Queue: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/main@{#78933}
This commit is contained in:
parent
42c279e00d
commit
a141d2a58d
@ -53,8 +53,6 @@ TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeAdd)
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeSubtract)
|
||||
/* Temporal #sec-temporal.plaindate.prototype.with */
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeWith)
|
||||
/* Temporal #sec-temporal.plaindate.prototype.withcalendar */
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeWithCalendar)
|
||||
/* Temporal #sec-temporal.plaindate.prototype.until */
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeUntil)
|
||||
/* Temporal #sec-temporal.plaindate.prototype.since */
|
||||
@ -133,8 +131,6 @@ TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeWith)
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeWithPlainTime)
|
||||
/* Temporal #sec-temporal.plaindatetime.prototype.withplainDate */
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeWithPlainDate)
|
||||
/* Temporal #sec-temporal.plaindatetime.prototype.withcalendar */
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeWithCalendar)
|
||||
/* Temporal #sec-temporal.plaindatetime.prototype.add */
|
||||
TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeAdd)
|
||||
/* Temporal #sec-temporal.plaindatetime.prototype.subtract */
|
||||
@ -205,8 +201,6 @@ TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainTime)
|
||||
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainDate)
|
||||
/* Temporal #sec-temporal.zoneddatetime.prototype.withtimezone */
|
||||
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithTimeZone)
|
||||
/* Temporal #sec-temporal.zoneddatetime.prototype.withcalendar */
|
||||
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithCalendar)
|
||||
/* Temporal #sec-temporal.zoneddatetime.prototype.add */
|
||||
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeAdd)
|
||||
/* Temporal #sec-temporal.zoneddatetime.prototype.subtract */
|
||||
@ -469,6 +463,16 @@ TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToLocaleString)
|
||||
RETURN_RESULT_OR_FAILURE(isolate, JSTemporal##T ::METHOD(isolate, obj)); \
|
||||
}
|
||||
|
||||
#define TEMPORAL_PROTOTYPE_METHOD1(T, METHOD, name) \
|
||||
BUILTIN(Temporal##T##Prototype##METHOD) { \
|
||||
HandleScope scope(isolate); \
|
||||
const char* method = "Temporal." #T ".prototype." #name; \
|
||||
CHECK_RECEIVER(JSTemporal##T, obj, method); \
|
||||
RETURN_RESULT_OR_FAILURE( \
|
||||
isolate, \
|
||||
JSTemporal##T ::METHOD(isolate, obj, args.atOrUndefined(isolate, 1))); \
|
||||
}
|
||||
|
||||
#define TEMPORAL_PROTOTYPE_METHOD3(T, METHOD, name) \
|
||||
BUILTIN(Temporal##T##Prototype##METHOD) { \
|
||||
HandleScope scope(isolate); \
|
||||
@ -579,6 +583,7 @@ TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DaysInMonth, daysInMonth)
|
||||
TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DaysInYear, daysInYear)
|
||||
TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, MonthsInYear, monthsInYear)
|
||||
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)
|
||||
|
||||
@ -630,6 +635,7 @@ TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DaysInYear, daysInYear)
|
||||
TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, MonthsInYear,
|
||||
monthsInYear)
|
||||
TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, InLeapYear, inLeapYear)
|
||||
TEMPORAL_PROTOTYPE_METHOD1(PlainDateTime, WithCalendar, withCalendar)
|
||||
TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, GetISOFields, getISOFields)
|
||||
TEMPORAL_VALUE_OF(PlainDateTime)
|
||||
|
||||
@ -737,6 +743,7 @@ TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Microsecond,
|
||||
iso_microsecond)
|
||||
TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Nanosecond,
|
||||
iso_nanosecond)
|
||||
TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithCalendar, withCalendar)
|
||||
TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, GetISOFields, getISOFields)
|
||||
TEMPORAL_VALUE_OF(ZonedDateTime)
|
||||
|
||||
|
@ -678,6 +678,15 @@ MaybeHandle<JSTemporalZonedDateTime> CreateTemporalZonedDateTime(
|
||||
return object;
|
||||
}
|
||||
|
||||
MaybeHandle<JSTemporalZonedDateTime> CreateTemporalZonedDateTime(
|
||||
Isolate* isolate, Handle<BigInt> epoch_nanoseconds,
|
||||
Handle<JSReceiver> time_zone, Handle<JSReceiver> calendar) {
|
||||
TEMPORAL_ENTER_FUNC();
|
||||
return CreateTemporalZonedDateTime(isolate, CONSTRUCTOR(zoned_date_time),
|
||||
CONSTRUCTOR(zoned_date_time),
|
||||
epoch_nanoseconds, time_zone, calendar);
|
||||
}
|
||||
|
||||
// #sec-temporal-createtemporalduration
|
||||
MaybeHandle<JSTemporalDuration> CreateTemporalDuration(
|
||||
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
|
||||
@ -3761,6 +3770,26 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Constructor(
|
||||
iso_day, calendar);
|
||||
}
|
||||
|
||||
// #sec-temporal.plaindate.prototype.withcalendar
|
||||
MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::WithCalendar(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date,
|
||||
Handle<Object> calendar_like) {
|
||||
const char* method = "Temporal.PlainDate.prototype.withCalendar";
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate,
|
||||
// [[InitializedTemporalDate]]).
|
||||
// 3. Let calendar be ? ToTemporalCalendar(calendar).
|
||||
Handle<JSReceiver> calendar;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
|
||||
ToTemporalCalendar(isolate, calendar_like, method),
|
||||
JSTemporalPlainDate);
|
||||
// 4. Return ? CreateTemporalDate(temporalDate.[[ISOYear]],
|
||||
// temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], calendar).
|
||||
return CreateTemporalDate(isolate, temporal_date->iso_year(),
|
||||
temporal_date->iso_month(),
|
||||
temporal_date->iso_day(), calendar);
|
||||
}
|
||||
|
||||
#define DEFINE_INT_FIELD(obj, str, field, item) \
|
||||
CHECK(JSReceiver::CreateDataProperty( \
|
||||
isolate, obj, factory->str##_string(), \
|
||||
@ -3840,6 +3869,32 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Constructor(
|
||||
millisecond, microsecond, nanosecond, calendar);
|
||||
}
|
||||
|
||||
// #sec-temporal.plaindatetime.prototype.withcalendar
|
||||
MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::WithCalendar(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time,
|
||||
Handle<Object> calendar_like) {
|
||||
const char* method = "Temporal.PlainDateTime.prototype.withCalendar";
|
||||
// 1. Let temporalDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDateTime,
|
||||
// [[InitializedTemporalDateTime]]).
|
||||
// 3. Let calendar be ? ToTemporalCalendar(calendar).
|
||||
Handle<JSReceiver> calendar;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
|
||||
ToTemporalCalendar(isolate, calendar_like, method),
|
||||
JSTemporalPlainDateTime);
|
||||
// 4. Return ? CreateTemporalDateTime(temporalDateTime.[[ISOYear]],
|
||||
// temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]],
|
||||
// temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]],
|
||||
// temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]],
|
||||
// temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]],
|
||||
// calendar).
|
||||
return temporal::CreateTemporalDateTime(
|
||||
isolate, date_time->iso_year(), date_time->iso_month(),
|
||||
date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(),
|
||||
date_time->iso_second(), date_time->iso_millisecond(),
|
||||
date_time->iso_microsecond(), date_time->iso_nanosecond(), calendar);
|
||||
}
|
||||
|
||||
// #sec-temporal.plaindatetime.prototype.getisofields
|
||||
MaybeHandle<JSReceiver> JSTemporalPlainDateTime::GetISOFields(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time) {
|
||||
@ -4151,6 +4206,28 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::Constructor(
|
||||
epoch_nanoseconds, time_zone, calendar);
|
||||
}
|
||||
|
||||
// #sec-temporal.zoneddatetime.prototype.withcalendar
|
||||
MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithCalendar(
|
||||
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time,
|
||||
Handle<Object> calendar_like) {
|
||||
TEMPORAL_ENTER_FUNC();
|
||||
const char* method = "Temporal.ZonedDateTime.prototype.withCalendar";
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime,
|
||||
// [[InitializedTemporalZonedDateTime]]).
|
||||
// 3. Let calendar be ? ToTemporalCalendar(calendarLike).
|
||||
Handle<JSReceiver> calendar;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
|
||||
ToTemporalCalendar(isolate, calendar_like, method),
|
||||
JSTemporalZonedDateTime);
|
||||
|
||||
// 4. Return ? CreateTemporalZonedDateTime(zonedDateTime.[[Nanoseconds]],
|
||||
// zonedDateTime.[[TimeZone]], calendar).
|
||||
Handle<BigInt> nanoseconds = handle(zoned_date_time->nanoseconds(), isolate);
|
||||
Handle<JSReceiver> time_zone = handle(zoned_date_time->time_zone(), isolate);
|
||||
return CreateTemporalZonedDateTime(isolate, nanoseconds, time_zone, calendar);
|
||||
}
|
||||
|
||||
// #sec-temporal.zoneddatetime.prototype.getisofields
|
||||
MaybeHandle<JSReceiver> JSTemporalZonedDateTime::GetISOFields(
|
||||
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time) {
|
||||
|
@ -114,6 +114,11 @@ class JSTemporalPlainDate
|
||||
Handle<Object> iso_month, Handle<Object> iso_day,
|
||||
Handle<Object> calendar_like);
|
||||
|
||||
// #sec-temporal.plaindate.prototype.withcalendar
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> WithCalendar(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date,
|
||||
Handle<Object> calendar_like);
|
||||
|
||||
// #sec-temporal.plaindate.prototype.getisofields
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date);
|
||||
@ -140,6 +145,11 @@ class JSTemporalPlainDateTime
|
||||
Handle<Object> microsecond, Handle<Object> nanosecond,
|
||||
Handle<Object> calendar_like);
|
||||
|
||||
// #sec-temporal.plaindatetime.prototype.withcalendar
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDateTime>
|
||||
WithCalendar(Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time,
|
||||
Handle<Object> calendar_like);
|
||||
|
||||
// #sec-temporal.plaindatetime.prototype.getisofields
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
|
||||
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time);
|
||||
@ -273,6 +283,12 @@ class JSTemporalZonedDateTime
|
||||
Handle<HeapObject> new_target, Handle<Object> epoch_nanoseconds,
|
||||
Handle<Object> time_zone_like, Handle<Object> calendar_like);
|
||||
|
||||
// #sec-temporal.zoneddatetime.prototype.withcalendar
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalZonedDateTime>
|
||||
WithCalendar(Isolate* isolate,
|
||||
Handle<JSTemporalZonedDateTime> zoned_date_time,
|
||||
Handle<Object> calendar_like);
|
||||
|
||||
// #sec-temporal.zoneddatetime.prototype.getisofields
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
|
||||
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time);
|
||||
|
@ -103,7 +103,6 @@
|
||||
'temporal/plain-date-time-to-plain-year-month': [FAIL],
|
||||
'temporal/plain-date-time-valueOf': [FAIL],
|
||||
'temporal/plain-date-time-with': [FAIL],
|
||||
'temporal/plain-date-time-with-calendar': [FAIL],
|
||||
'temporal/plain-date-time-with-plain-date': [FAIL],
|
||||
'temporal/plain-date-time-with-plain-time': [FAIL],
|
||||
'temporal/plain-date-to-json': [FAIL],
|
||||
@ -112,7 +111,6 @@
|
||||
'temporal/plain-date-to-plain-year-month': [FAIL],
|
||||
'temporal/plain-date-valueOf': [FAIL],
|
||||
'temporal/plain-date-with': [FAIL],
|
||||
'temporal/plain-date-with-calendar': [FAIL],
|
||||
|
||||
##############################################################################
|
||||
# Open bugs.
|
||||
|
@ -1264,12 +1264,9 @@
|
||||
'built-ins/Temporal/PlainDate/prototype/with/basic': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/with/branding': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/withCalendar/basic': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/withCalendar/branding': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-temporal-object': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/with/calendar-fields-iterable': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/with/calendar-merge-fields-returns-primitive': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/withCalendar/missing-argument': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/withCalendar/subclassing-ignored': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/with/copies-merge-fields-object': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/with/infinity-throws-rangeerror': [FAIL],
|
||||
'built-ins/Temporal/PlainDate/prototype/with/options-invalid': [FAIL],
|
||||
@ -1501,8 +1498,6 @@
|
||||
'built-ins/Temporal/PlainDateTime/prototype/until/smallestunit-undefined': [FAIL],
|
||||
'built-ins/Temporal/PlainDateTime/prototype/until/smallestunit-wrong-type': [FAIL],
|
||||
'built-ins/Temporal/PlainDateTime/prototype/with/branding': [FAIL],
|
||||
'built-ins/Temporal/PlainDateTime/prototype/withCalendar/branding': [FAIL],
|
||||
'built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-temporal-object': [FAIL],
|
||||
'built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-iterable': [FAIL],
|
||||
'built-ins/Temporal/PlainDateTime/prototype/with/calendar-merge-fields-returns-primitive': [FAIL],
|
||||
'built-ins/Temporal/PlainDateTime/prototype/withCalendar/missing-argument': [FAIL],
|
||||
@ -2380,8 +2375,6 @@
|
||||
'built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
|
||||
'built-ins/Temporal/ZonedDateTime/prototype/with/balance-negative-time-units': [FAIL],
|
||||
'built-ins/Temporal/ZonedDateTime/prototype/with/branding': [FAIL],
|
||||
'built-ins/Temporal/ZonedDateTime/prototype/withCalendar/branding': [FAIL],
|
||||
'built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-temporal-object': [FAIL],
|
||||
'built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-iterable': [FAIL],
|
||||
'built-ins/Temporal/ZonedDateTime/prototype/with/calendar-merge-fields-returns-primitive': [FAIL],
|
||||
'built-ins/Temporal/ZonedDateTime/prototype/withCalendar/missing-argument': [FAIL],
|
||||
|
Loading…
Reference in New Issue
Block a user