[Temporal] Add ZonedDateTime withTimeZone
Bug: v8:11544 Change-Id: I72e005c0937418f4160e763edc4fd2b81b14b9c0 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3385604 Reviewed-by: Shu-yu Guo <syg@chromium.org> Commit-Queue: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/main@{#78966}
This commit is contained in:
parent
ec4b7835cb
commit
c705272afe
@ -199,8 +199,6 @@ TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWith)
|
|||||||
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainTime)
|
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainTime)
|
||||||
/* Temporal #sec-temporal.zoneddatetime.prototype.withplaindate */
|
/* Temporal #sec-temporal.zoneddatetime.prototype.withplaindate */
|
||||||
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainDate)
|
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainDate)
|
||||||
/* Temporal #sec-temporal.zoneddatetime.prototype.withtimezone */
|
|
||||||
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithTimeZone)
|
|
||||||
/* Temporal #sec-temporal.zoneddatetime.prototype.add */
|
/* Temporal #sec-temporal.zoneddatetime.prototype.add */
|
||||||
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeAdd)
|
TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeAdd)
|
||||||
/* Temporal #sec-temporal.zoneddatetime.prototype.subtract */
|
/* Temporal #sec-temporal.zoneddatetime.prototype.subtract */
|
||||||
@ -744,6 +742,7 @@ TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Microsecond,
|
|||||||
TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Nanosecond,
|
TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Nanosecond,
|
||||||
iso_nanosecond)
|
iso_nanosecond)
|
||||||
TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithCalendar, withCalendar)
|
TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithCalendar, withCalendar)
|
||||||
|
TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithTimeZone, withTimeZone)
|
||||||
TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, GetISOFields, getISOFields)
|
TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, GetISOFields, getISOFields)
|
||||||
TEMPORAL_VALUE_OF(ZonedDateTime)
|
TEMPORAL_VALUE_OF(ZonedDateTime)
|
||||||
|
|
||||||
|
@ -4230,6 +4230,30 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithCalendar(
|
|||||||
return CreateTemporalZonedDateTime(isolate, nanoseconds, time_zone, calendar);
|
return CreateTemporalZonedDateTime(isolate, nanoseconds, time_zone, calendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #sec-temporal.zoneddatetime.prototype.withtimezone
|
||||||
|
MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithTimeZone(
|
||||||
|
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time,
|
||||||
|
Handle<Object> time_zone_like) {
|
||||||
|
TEMPORAL_ENTER_FUNC();
|
||||||
|
const char* method = "Temporal.ZonedDateTime.prototype.withTimeZone";
|
||||||
|
// 1. Let zonedDateTime be the this value.
|
||||||
|
// 2. Perform ? RequireInternalSlot(zonedDateTime,
|
||||||
|
// [[InitializedTemporalZonedDateTime]]).
|
||||||
|
// 3. Let timeZone be ? ToTemporalTimeZone(timeZoneLike).
|
||||||
|
Handle<JSReceiver> time_zone;
|
||||||
|
ASSIGN_RETURN_ON_EXCEPTION(
|
||||||
|
isolate, time_zone, ToTemporalTimeZone(isolate, time_zone_like, method),
|
||||||
|
JSTemporalZonedDateTime);
|
||||||
|
|
||||||
|
// 4. Return ? CreateTemporalZonedDateTime(zonedDateTime.[[Nanoseconds]],
|
||||||
|
// timeZone, zonedDateTime.[[Calendar]]).
|
||||||
|
Handle<BigInt> nanoseconds =
|
||||||
|
Handle<BigInt>(zoned_date_time->nanoseconds(), isolate);
|
||||||
|
Handle<JSReceiver> calendar =
|
||||||
|
Handle<JSReceiver>(zoned_date_time->calendar(), isolate);
|
||||||
|
return CreateTemporalZonedDateTime(isolate, nanoseconds, time_zone, calendar);
|
||||||
|
}
|
||||||
|
|
||||||
// #sec-temporal.zoneddatetime.prototype.getisofields
|
// #sec-temporal.zoneddatetime.prototype.getisofields
|
||||||
MaybeHandle<JSReceiver> JSTemporalZonedDateTime::GetISOFields(
|
MaybeHandle<JSReceiver> JSTemporalZonedDateTime::GetISOFields(
|
||||||
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time) {
|
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time) {
|
||||||
|
@ -289,6 +289,12 @@ class JSTemporalZonedDateTime
|
|||||||
Handle<JSTemporalZonedDateTime> zoned_date_time,
|
Handle<JSTemporalZonedDateTime> zoned_date_time,
|
||||||
Handle<Object> calendar_like);
|
Handle<Object> calendar_like);
|
||||||
|
|
||||||
|
// #sec-temporal.zoneddatetime.prototype.withtimezone
|
||||||
|
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalZonedDateTime>
|
||||||
|
WithTimeZone(Isolate* isolate,
|
||||||
|
Handle<JSTemporalZonedDateTime> zoned_date_time,
|
||||||
|
Handle<Object> time_zone_like);
|
||||||
|
|
||||||
// #sec-temporal.zoneddatetime.prototype.getisofields
|
// #sec-temporal.zoneddatetime.prototype.getisofields
|
||||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
|
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
|
||||||
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time);
|
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time);
|
||||||
|
@ -2424,7 +2424,6 @@
|
|||||||
'built-ins/Temporal/ZonedDateTime/prototype/with/read-time-fields-before-datefromfields': [FAIL],
|
'built-ins/Temporal/ZonedDateTime/prototype/with/read-time-fields-before-datefromfields': [FAIL],
|
||||||
'built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken': [FAIL],
|
'built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken': [FAIL],
|
||||||
'built-ins/Temporal/ZonedDateTime/prototype/with/subclassing-ignored': [FAIL],
|
'built-ins/Temporal/ZonedDateTime/prototype/with/subclassing-ignored': [FAIL],
|
||||||
'built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/branding': [FAIL],
|
|
||||||
'built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
|
'built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
|
||||||
'built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
|
'built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
|
||||||
'built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
|
'built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
|
||||||
|
Loading…
Reference in New Issue
Block a user