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

[Temporal] Implement Temporal.Now.*

Bug: v8:11544
Change-Id: I5dda2845618cc7c709fb9ddac337472e112407e4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3374281Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79359}
parent 326a63a9
......@@ -16,28 +16,27 @@ namespace internal {
UNIMPLEMENTED(); \
}
/* Temporal #sec-temporal.now.timezone */
TO_BE_IMPLEMENTED(TemporalNowTimeZone)
/* Temporal #sec-temporal.now.instant */
TO_BE_IMPLEMENTED(TemporalNowInstant)
/* Temporal #sec-temporal.now.plaindatetime */
TO_BE_IMPLEMENTED(TemporalNowPlainDateTime)
/* Temporal #sec-temporal.now.plaindatetimeiso */
TO_BE_IMPLEMENTED(TemporalNowPlainDateTimeISO)
/* Temporal #sec-temporal.now.zoneddatetime */
TO_BE_IMPLEMENTED(TemporalNowZonedDateTime)
/* Temporal #sec-temporal.now.zoneddatetimeiso */
TO_BE_IMPLEMENTED(TemporalNowZonedDateTimeISO)
/* Temporal #sec-temporal.now.plaindate */
TO_BE_IMPLEMENTED(TemporalNowPlainDate)
/* Temporal #sec-temporal.now.plaindateiso */
TO_BE_IMPLEMENTED(TemporalNowPlainDateISO)
/* There is no Temporal.now.plainTime. See
* https://github.com/tc39/proposal-temporal/issues/1540 */
/* Temporal #sec-temporal.now.plaintimeiso */
TO_BE_IMPLEMENTED(TemporalNowPlainTimeISO)
#define TEMPORAL_NOW0(T) \
BUILTIN(TemporalNow##T) { \
HandleScope scope(isolate); \
RETURN_RESULT_OR_FAILURE(isolate, JSTemporal##T::Now(isolate)); \
}
#define TEMPORAL_NOW2(T) \
BUILTIN(TemporalNow##T) { \
HandleScope scope(isolate); \
RETURN_RESULT_OR_FAILURE( \
isolate, JSTemporal##T::Now(isolate, args.atOrUndefined(isolate, 1), \
args.atOrUndefined(isolate, 2))); \
}
#define TEMPORAL_NOW_ISO1(T) \
BUILTIN(TemporalNow##T##ISO) { \
HandleScope scope(isolate); \
RETURN_RESULT_OR_FAILURE( \
isolate, \
JSTemporal##T::NowISO(isolate, args.atOrUndefined(isolate, 1))); \
}
/* Temporal #sec-temporal.plaindate.from */
TO_BE_IMPLEMENTED(TemporalPlainDateFrom)
......@@ -537,6 +536,20 @@ TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToLocaleString)
date_like)); \
}
// Now
TEMPORAL_NOW0(TimeZone)
TEMPORAL_NOW0(Instant)
TEMPORAL_NOW2(PlainDateTime)
TEMPORAL_NOW_ISO1(PlainDateTime)
TEMPORAL_NOW2(PlainDate)
TEMPORAL_NOW_ISO1(PlainDate)
// There is NO Temporal.now.plainTime
// See https://github.com/tc39/proposal-temporal/issues/1540
TEMPORAL_NOW_ISO1(PlainTime)
TEMPORAL_NOW2(ZonedDateTime)
TEMPORAL_NOW_ISO1(ZonedDateTime)
// PlainDate
BUILTIN(TemporalPlainDateConstructor) {
HandleScope scope(isolate);
......
This diff is collapsed.
......@@ -99,6 +99,10 @@ class JSTemporalInstant
Isolate* isolate, Handle<JSFunction> target,
Handle<HeapObject> new_target, Handle<Object> epoch_nanoseconds);
// #sec-temporal.now.instant
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalInstant> Now(
Isolate* isolate);
DECL_PRINTER(JSTemporalInstant)
TQ_OBJECT_CONSTRUCTORS(JSTemporalInstant)
......@@ -123,6 +127,14 @@ class JSTemporalPlainDate
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date);
// #sec-temporal.now.plaindate
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> Now(
Isolate* isolate, Handle<Object> calendar_like,
Handle<Object> temporal_time_zone_like);
// #sec-temporal.now.plaindateiso
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDate> NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like);
DECL_PRINTER(JSTemporalPlainDate)
DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY()
......@@ -154,6 +166,15 @@ class JSTemporalPlainDateTime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time);
// #sec-temporal.now.plaindatetime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDateTime> Now(
Isolate* isolate, Handle<Object> calendar_like,
Handle<Object> temporal_time_zone_like);
// #sec-temporal.now.plaindatetimeiso
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainDateTime> NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like);
DECL_PRINTER(JSTemporalPlainDateTime)
DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY()
......@@ -204,6 +225,10 @@ class JSTemporalPlainTime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainTime> plain_time);
// #sec-temporal.now.plaintimeiso
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalPlainTime> NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like);
DECL_PRINTER(JSTemporalPlainTime)
DEFINE_TORQUE_GENERATED_JS_TEMPORAL_HOUR_MINUTE_SECOND()
......@@ -243,6 +268,10 @@ class JSTemporalPlainYearMonth
class JSTemporalTimeZone
: public TorqueGeneratedJSTemporalTimeZone<JSTemporalTimeZone, JSObject> {
public:
// #sec-temporal.now.timezone
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalTimeZone> Now(
Isolate* isolate);
// #sec-temporal.timezone
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalTimeZone> Constructor(
Isolate* isolate, Handle<JSFunction> target,
......@@ -299,6 +328,15 @@ class JSTemporalZonedDateTime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time);
// #sec-temporal.now.zoneddatetime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalZonedDateTime> Now(
Isolate* isolate, Handle<Object> calendar_like,
Handle<Object> temporal_time_zone_like);
// #sec-temporal.now.zoneddatetimeiso
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalZonedDateTime> NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like);
DECL_PRINTER(JSTemporalZonedDateTime)
TQ_OBJECT_CONSTRUCTORS(JSTemporalZonedDateTime)
......
......@@ -79,7 +79,6 @@
'temporal/instant-subtract': [FAIL],
'temporal/instant-to-json': [FAIL],
'temporal/instant-toJSON': [FAIL],
'temporal/instant-valueOf': [FAIL],
'temporal/plain-date-add': [FAIL],
'temporal/plain-date-compare': [FAIL],
'temporal/plain-date-equals': [FAIL],
......
......@@ -954,95 +954,20 @@
'built-ins/Temporal/Instant/prototype/until/smallestunit-plurals-accepted': [FAIL],
'built-ins/Temporal/Instant/prototype/until/smallestunit-undefined': [FAIL],
'built-ins/Temporal/Instant/prototype/until/smallestunit-wrong-type': [FAIL],
'built-ins/Temporal/Now/instant/return-value-distinct': [FAIL],
'built-ins/Temporal/Now/instant/return-value-prototype': [FAIL],
'built-ins/Temporal/Now/instant/return-value-value': [FAIL],
'built-ins/Temporal/Now/plainDate/calendar-temporal-object': [FAIL],
'built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/Now/plainDateISO/timezone-string-datetime': [FAIL],
'built-ins/Temporal/Now/plainDateTime/calendar-function': [FAIL],
'built-ins/Temporal/Now/plainDateTime/calendar-object': [FAIL],
'built-ins/Temporal/Now/plainDateTime/calendar-object-fail-call-tostring': [FAIL],
'built-ins/Temporal/Now/plainDateTime/calendar-object-fail-get-calendar': [FAIL],
'built-ins/Temporal/Now/plainDateTime/calendar-object-fail-has-calendar': [FAIL],
'built-ins/Temporal/Now/plainDateTime/calendar-object-fail-has-nested-calendar': [FAIL],
'built-ins/Temporal/Now/plainDateTime/calendar-temporal-object': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/return-value': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-invocation': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-non-method': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-not-a-number': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-poisoned': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-throws': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-object': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-object-fail-call-tostring': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-object-fail-get-timezone': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-object-fail-has-nested-timezone': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-object-fail-has-timezone': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/timezone-string-datetime': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/time-zone-undefined': [FAIL],
'built-ins/Temporal/Now/plainDateTime/return-value': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-invocation': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-non-method': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-not-a-number': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-poisoned': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-throws': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-object': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-object-fail-call-tostring': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-object-fail-get-timezone': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-object-fail-has-nested-timezone': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-object-fail-has-timezone': [FAIL],
'built-ins/Temporal/Now/plainDateTime/timezone-string-datetime': [FAIL],
'built-ins/Temporal/Now/plainDateTime/time-zone-undefined': [FAIL],
'built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/Now/plainDate/timezone-string-datetime': [FAIL],
'built-ins/Temporal/Now/plainDate/toPlainDate-override': [FAIL],
'built-ins/Temporal/Now/plainTimeISO/timezone': [FAIL],
'built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-non-integer': [FAIL],
'built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-not-callable': [FAIL],
'built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-out-of-range': [FAIL],
'built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-wrong-type': [FAIL],
'built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime': [FAIL],
'built-ins/Temporal/Now/plainTimeISO/toPlainTime-override': [FAIL],
'built-ins/Temporal/Now/timeZone/new-object': [FAIL],
'built-ins/Temporal/Now/timeZone/return-value': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/calendar-function': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/calendar-object': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/calendar-object-fail-call-tostring': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/calendar-object-fail-get-calendar': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/calendar-object-fail-has-calendar': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/calendar-object-fail-has-nested-calendar': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/calendar-temporal-object': [FAIL],
'built-ins/Temporal/Now/zonedDateTimeISO/timezone-object': [FAIL],
'built-ins/Temporal/Now/zonedDateTimeISO/timezone-object-fail-call-tostring': [FAIL],
'built-ins/Temporal/Now/zonedDateTimeISO/timezone-object-fail-get-timezone': [FAIL],
'built-ins/Temporal/Now/zonedDateTimeISO/timezone-object-fail-has-nested-timezone': [FAIL],
'built-ins/Temporal/Now/zonedDateTimeISO/timezone-object-fail-has-timezone': [FAIL],
'built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-datetime': [FAIL],
'built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/Now/zonedDateTimeISO/time-zone-undefined': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/timezone-object': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/timezone-object-fail-call-tostring': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/timezone-object-fail-get-timezone': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/timezone-object-fail-has-nested-timezone': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/timezone-object-fail-has-timezone': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/timezone-string-datetime': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/time-zone-undefined': [FAIL],
'built-ins/Temporal/PlainDate/basic': [FAIL],
'built-ins/Temporal/PlainDate/compare/argument-object': [FAIL],
'built-ins/Temporal/PlainDate/compare/argument-plaindatetime': [FAIL],
......@@ -2438,8 +2363,6 @@
'intl402/Temporal/Instant/prototype/toLocaleString/options-conflict': [FAIL],
'intl402/Temporal/Instant/prototype/toLocaleString/options-undefined': [FAIL],
'intl402/Temporal/Now/plainDateTimeISO/timezone-string-datetime': [FAIL],
'intl402/Temporal/Now/zonedDateTimeISO/timezone-string-datetime': [FAIL],
'intl402/Temporal/Now/zonedDateTime/timezone-string-datetime': [FAIL],
'intl402/Temporal/PlainDate/compare/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/PlainDate/from/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/PlainDate/prototype/equals/infinity-throws-rangeerror': [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