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 { ...@@ -16,28 +16,27 @@ namespace internal {
UNIMPLEMENTED(); \ UNIMPLEMENTED(); \
} }
/* Temporal #sec-temporal.now.timezone */ #define TEMPORAL_NOW0(T) \
TO_BE_IMPLEMENTED(TemporalNowTimeZone) BUILTIN(TemporalNow##T) { \
/* Temporal #sec-temporal.now.instant */ HandleScope scope(isolate); \
TO_BE_IMPLEMENTED(TemporalNowInstant) RETURN_RESULT_OR_FAILURE(isolate, JSTemporal##T::Now(isolate)); \
/* Temporal #sec-temporal.now.plaindatetime */ }
TO_BE_IMPLEMENTED(TemporalNowPlainDateTime)
/* Temporal #sec-temporal.now.plaindatetimeiso */ #define TEMPORAL_NOW2(T) \
TO_BE_IMPLEMENTED(TemporalNowPlainDateTimeISO) BUILTIN(TemporalNow##T) { \
/* Temporal #sec-temporal.now.zoneddatetime */ HandleScope scope(isolate); \
TO_BE_IMPLEMENTED(TemporalNowZonedDateTime) RETURN_RESULT_OR_FAILURE( \
/* Temporal #sec-temporal.now.zoneddatetimeiso */ isolate, JSTemporal##T::Now(isolate, args.atOrUndefined(isolate, 1), \
TO_BE_IMPLEMENTED(TemporalNowZonedDateTimeISO) args.atOrUndefined(isolate, 2))); \
/* Temporal #sec-temporal.now.plaindate */ }
TO_BE_IMPLEMENTED(TemporalNowPlainDate)
/* Temporal #sec-temporal.now.plaindateiso */ #define TEMPORAL_NOW_ISO1(T) \
TO_BE_IMPLEMENTED(TemporalNowPlainDateISO) BUILTIN(TemporalNow##T##ISO) { \
HandleScope scope(isolate); \
/* There is no Temporal.now.plainTime. See RETURN_RESULT_OR_FAILURE( \
* https://github.com/tc39/proposal-temporal/issues/1540 */ isolate, \
JSTemporal##T::NowISO(isolate, args.atOrUndefined(isolate, 1))); \
/* Temporal #sec-temporal.now.plaintimeiso */ }
TO_BE_IMPLEMENTED(TemporalNowPlainTimeISO)
/* Temporal #sec-temporal.plaindate.from */ /* Temporal #sec-temporal.plaindate.from */
TO_BE_IMPLEMENTED(TemporalPlainDateFrom) TO_BE_IMPLEMENTED(TemporalPlainDateFrom)
...@@ -537,6 +536,20 @@ TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToLocaleString) ...@@ -537,6 +536,20 @@ TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToLocaleString)
date_like)); \ 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 // PlainDate
BUILTIN(TemporalPlainDateConstructor) { BUILTIN(TemporalPlainDateConstructor) {
HandleScope scope(isolate); HandleScope scope(isolate);
......
...@@ -124,14 +124,14 @@ V8_WARN_UNUSED_RESULT Maybe<bool> BalanceDuration( ...@@ -124,14 +124,14 @@ V8_WARN_UNUSED_RESULT Maybe<bool> BalanceDuration(
Isolate* isolate, int64_t* days, int64_t* hours, int64_t* minutes, Isolate* isolate, int64_t* days, int64_t* hours, int64_t* minutes,
int64_t* seconds, int64_t* milliseconds, int64_t* microseconds, int64_t* seconds, int64_t* milliseconds, int64_t* microseconds,
int64_t* nanoseconds, Unit largest_unit, Handle<Object> relative_to, int64_t* nanoseconds, Unit largest_unit, Handle<Object> relative_to,
const char* method); const char* method_name);
V8_WARN_UNUSED_RESULT Maybe<DurationRecord> DifferenceISODateTime( V8_WARN_UNUSED_RESULT Maybe<DurationRecord> DifferenceISODateTime(
Isolate* isolate, int32_t y1, int32_t mon1, int32_t d1, int32_t h1, Isolate* isolate, int32_t y1, int32_t mon1, int32_t d1, int32_t h1,
int32_t min1, int32_t s1, int32_t ms1, int32_t mus1, int32_t ns1, int32_t min1, int32_t s1, int32_t ms1, int32_t mus1, int32_t ns1,
int32_t y2, int32_t mon2, int32_t d2, int32_t h2, int32_t min2, int32_t s2, int32_t y2, int32_t mon2, int32_t d2, int32_t h2, int32_t min2, int32_t s2,
int32_t ms2, int32_t mus2, int32_t ns2, Handle<JSReceiver> calendar, int32_t ms2, int32_t mus2, int32_t ns2, Handle<JSReceiver> calendar,
Unit largest_unit, Handle<Object> relative_to, const char* method); Unit largest_unit, Handle<Object> relative_to, const char* method_name);
// #sec-temporal-adddatetime // #sec-temporal-adddatetime
V8_WARN_UNUSED_RESULT Maybe<DateTimeRecordCommon> AddDateTime( V8_WARN_UNUSED_RESULT Maybe<DateTimeRecordCommon> AddDateTime(
...@@ -144,13 +144,13 @@ V8_WARN_UNUSED_RESULT Maybe<DateTimeRecordCommon> AddDateTime( ...@@ -144,13 +144,13 @@ V8_WARN_UNUSED_RESULT Maybe<DateTimeRecordCommon> AddDateTime(
V8_WARN_UNUSED_RESULT MaybeHandle<BigInt> AddZonedDateTime( V8_WARN_UNUSED_RESULT MaybeHandle<BigInt> AddZonedDateTime(
Isolate* isolate, Handle<BigInt> eopch_nanoseconds, Isolate* isolate, Handle<BigInt> eopch_nanoseconds,
Handle<JSReceiver> time_zone, Handle<JSReceiver> calendar, Handle<JSReceiver> time_zone, Handle<JSReceiver> calendar,
const DurationRecord& duration, const char* method); const DurationRecord& duration, const char* method_name);
V8_WARN_UNUSED_RESULT MaybeHandle<BigInt> AddZonedDateTime( V8_WARN_UNUSED_RESULT MaybeHandle<BigInt> AddZonedDateTime(
Isolate* isolate, Handle<BigInt> eopch_nanoseconds, Isolate* isolate, Handle<BigInt> eopch_nanoseconds,
Handle<JSReceiver> time_zone, Handle<JSReceiver> calendar, Handle<JSReceiver> time_zone, Handle<JSReceiver> calendar,
const DurationRecord& duration, Handle<JSReceiver> options, const DurationRecord& duration, Handle<JSReceiver> options,
const char* method); const char* method_name);
// #sec-temporal-isvalidepochnanoseconds // #sec-temporal-isvalidepochnanoseconds
bool IsValidEpochNanoseconds(Isolate* isolate, bool IsValidEpochNanoseconds(Isolate* isolate,
...@@ -164,12 +164,12 @@ V8_WARN_UNUSED_RESULT Maybe<bool> NanosecondsToDays( ...@@ -164,12 +164,12 @@ V8_WARN_UNUSED_RESULT Maybe<bool> NanosecondsToDays(
Isolate* isolate, Handle<BigInt> nanoseconds, Isolate* isolate, Handle<BigInt> nanoseconds,
Handle<Object> relative_to_obj, int64_t* result_days, Handle<Object> relative_to_obj, int64_t* result_days,
int64_t* result_nanoseconds, int64_t* result_day_length, int64_t* result_nanoseconds, int64_t* result_day_length,
const char* method); const char* method_name);
V8_WARN_UNUSED_RESULT Maybe<bool> NanosecondsToDays( V8_WARN_UNUSED_RESULT Maybe<bool> NanosecondsToDays(
Isolate* isolate, int64_t nanoseconds, Handle<Object> relative_to_obj, Isolate* isolate, int64_t nanoseconds, Handle<Object> relative_to_obj,
int64_t* result_days, int64_t* resultj_nanoseconds, int64_t* result_days, int64_t* resultj_nanoseconds,
int64_t* result_day_length, const char* method); int64_t* result_day_length, const char* method_name);
// #sec-temporal-interpretisodatetimeoffset // #sec-temporal-interpretisodatetimeoffset
enum class OffsetBehaviour { kOption, kExact, kWall }; enum class OffsetBehaviour { kOption, kExact, kWall };
...@@ -240,7 +240,7 @@ V8_WARN_UNUSED_RESULT MaybeHandle<JSTemporalDuration> CalendarDateUntil( ...@@ -240,7 +240,7 @@ V8_WARN_UNUSED_RESULT MaybeHandle<JSTemporalDuration> CalendarDateUntil(
// #sec-temporal-getoffsetnanosecondsfor // #sec-temporal-getoffsetnanosecondsfor
V8_WARN_UNUSED_RESULT Maybe<int64_t> GetOffsetNanosecondsFor( V8_WARN_UNUSED_RESULT Maybe<int64_t> GetOffsetNanosecondsFor(
Isolate* isolate, Handle<JSReceiver> time_zone, Handle<Object> instant, Isolate* isolate, Handle<JSReceiver> time_zone, Handle<Object> instant,
const char* method); const char* method_name);
bool IsBuiltinCalendar(Isolate* isolate, Handle<String> id); bool IsBuiltinCalendar(Isolate* isolate, Handle<String> id);
...@@ -288,6 +288,14 @@ inline int64_t modulo(int64_t a, int64_t b) { ...@@ -288,6 +288,14 @@ inline int64_t modulo(int64_t a, int64_t b) {
MessageTemplate::kInvalidTimeValueForTemporal, \ MessageTemplate::kInvalidTimeValueForTemporal, \
isolate->factory()->NewStringFromStaticChars(TEMPORAL_DEBUG_INFO)) isolate->factory()->NewStringFromStaticChars(TEMPORAL_DEBUG_INFO))
// #sec-defaulttimezone
MaybeHandle<String> DefaultTimeZone(Isolate* isolate) {
TEMPORAL_ENTER_FUNC();
// For now, always return "UTC"
// TODO(ftang) implement behavior specified in #sup-defaulttimezone
return isolate->factory()->UTC_string();
}
// #sec-temporal-isodatetimewithinlimits // #sec-temporal-isodatetimewithinlimits
bool ISODateTimeWithinLimits(Isolate* isolate, int32_t year, int32_t month, bool ISODateTimeWithinLimits(Isolate* isolate, int32_t year, int32_t month,
int32_t day, int32_t hour, int32_t minute, int32_t day, int32_t hour, int32_t minute,
...@@ -367,6 +375,21 @@ bool ISOYearMonthWithinLimits(int32_t year, int32_t month) { ...@@ -367,6 +375,21 @@ bool ISOYearMonthWithinLimits(int32_t year, int32_t month) {
isolate->context().native_context().temporal_##name##_function()), \ isolate->context().native_context().temporal_##name##_function()), \
isolate) isolate)
// #sec-temporal-systemutcepochnanoseconds
MaybeHandle<BigInt> SystemUTCEpochNanoseconds(Isolate* isolate) {
TEMPORAL_ENTER_FUNC();
// 1. Let ns be the approximate current UTC date and time, in nanoseconds
// since the epoch.
double ms = V8::GetCurrentPlatform()->CurrentClockTimeMillis();
// 2. Set ns to the result of clamping ns between −8.64 × 10^21 and 8.64 ×
// 10^21.
// 3. Return ℤ(ns).
double ns = ms * 1000000.0;
ns = std::floor(std::max(-8.64e21, std::min(ns, 8.64e21)));
return BigInt::FromNumber(isolate, isolate->factory()->NewNumber(ns));
}
// #sec-temporal-createtemporalcalendar // #sec-temporal-createtemporalcalendar
MaybeHandle<JSTemporalCalendar> CreateTemporalCalendar( MaybeHandle<JSTemporalCalendar> CreateTemporalCalendar(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target, Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
...@@ -581,7 +604,16 @@ MaybeHandle<JSTemporalPlainTime> CreateTemporalTime( ...@@ -581,7 +604,16 @@ MaybeHandle<JSTemporalPlainTime> CreateTemporalTime(
// 12. Return object. // 12. Return object.
return object; return object;
} }
MaybeHandle<JSTemporalPlainTime> CreateTemporalTime(
Isolate* isolate, int32_t hour, int32_t minute, int32_t second,
int32_t millisecond, int32_t microsecond, int32_t nanosecond) {
TEMPORAL_ENTER_FUNC();
return CreateTemporalTime(isolate, CONSTRUCTOR(plain_time),
CONSTRUCTOR(plain_time), hour, minute, second,
millisecond, microsecond, nanosecond);
}
// #sec-temporal-createtemporalmonthday
MaybeHandle<JSTemporalPlainMonthDay> CreateTemporalMonthDay( MaybeHandle<JSTemporalPlainMonthDay> CreateTemporalMonthDay(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target, Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
int32_t iso_month, int32_t iso_day, Handle<JSReceiver> calendar, int32_t iso_month, int32_t iso_day, Handle<JSReceiver> calendar,
...@@ -677,7 +709,6 @@ MaybeHandle<JSTemporalZonedDateTime> CreateTemporalZonedDateTime( ...@@ -677,7 +709,6 @@ MaybeHandle<JSTemporalZonedDateTime> CreateTemporalZonedDateTime(
// 10. Return object. // 10. Return object.
return object; return object;
} }
MaybeHandle<JSTemporalZonedDateTime> CreateTemporalZonedDateTime( MaybeHandle<JSTemporalZonedDateTime> CreateTemporalZonedDateTime(
Isolate* isolate, Handle<BigInt> epoch_nanoseconds, Isolate* isolate, Handle<BigInt> epoch_nanoseconds,
Handle<JSReceiver> time_zone, Handle<JSReceiver> calendar) { Handle<JSReceiver> time_zone, Handle<JSReceiver> calendar) {
...@@ -873,6 +904,26 @@ MaybeHandle<JSTemporalTimeZone> CreateTemporalTimeZone( ...@@ -873,6 +904,26 @@ MaybeHandle<JSTemporalTimeZone> CreateTemporalTimeZone(
namespace { namespace {
// #sec-temporal-systeminstant
MaybeHandle<JSTemporalInstant> SystemInstant(Isolate* isolate) {
TEMPORAL_ENTER_FUNC();
// 1. Let ns be ! SystemUTCEpochNanoseconds().
Handle<BigInt> ns;
ASSIGN_RETURN_ON_EXCEPTION(isolate, ns, SystemUTCEpochNanoseconds(isolate),
JSTemporalInstant);
// 2. Return ? CreateTemporalInstant(ns).
return temporal::CreateTemporalInstant(isolate, ns);
}
// #sec-temporal-systemtimezone
MaybeHandle<JSTemporalTimeZone> SystemTimeZone(Isolate* isolate) {
TEMPORAL_ENTER_FUNC();
Handle<String> default_time_zone;
ASSIGN_RETURN_ON_EXCEPTION(isolate, default_time_zone,
DefaultTimeZone(isolate), JSTemporalTimeZone);
return temporal::CreateTemporalTimeZone(isolate, default_time_zone);
}
Maybe<DateTimeRecordCommon> GetISOPartsFromEpoch( Maybe<DateTimeRecordCommon> GetISOPartsFromEpoch(
Isolate* isolate, Handle<BigInt> epoch_nanoseconds) { Isolate* isolate, Handle<BigInt> epoch_nanoseconds) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
...@@ -991,11 +1042,11 @@ namespace temporal { ...@@ -991,11 +1042,11 @@ namespace temporal {
MaybeHandle<JSTemporalPlainDateTime> BuiltinTimeZoneGetPlainDateTimeFor( MaybeHandle<JSTemporalPlainDateTime> BuiltinTimeZoneGetPlainDateTimeFor(
Isolate* isolate, Handle<JSReceiver> time_zone, Isolate* isolate, Handle<JSReceiver> time_zone,
Handle<JSTemporalInstant> instant, Handle<JSReceiver> calendar, Handle<JSTemporalInstant> instant, Handle<JSReceiver> calendar,
const char* method) { const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 1. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant). // 1. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant).
Maybe<int64_t> maybe_offset_nanoseconds = Maybe<int64_t> maybe_offset_nanoseconds =
GetOffsetNanosecondsFor(isolate, time_zone, instant, method); GetOffsetNanosecondsFor(isolate, time_zone, instant, method_name);
MAYBE_RETURN(maybe_offset_nanoseconds, Handle<JSTemporalPlainDateTime>()); MAYBE_RETURN(maybe_offset_nanoseconds, Handle<JSTemporalPlainDateTime>());
// 2. Let result be ! GetISOPartsFromEpoch(instant.[[Nanoseconds]]). // 2. Let result be ! GetISOPartsFromEpoch(instant.[[Nanoseconds]]).
Maybe<DateTimeRecordCommon> maybe_result = GetISOPartsFromEpoch( Maybe<DateTimeRecordCommon> maybe_result = GetISOPartsFromEpoch(
...@@ -1074,7 +1125,7 @@ MaybeHandle<FixedArray> GetPossibleInstantsFor(Isolate* isolate, ...@@ -1074,7 +1125,7 @@ MaybeHandle<FixedArray> GetPossibleInstantsFor(Isolate* isolate,
MaybeHandle<JSTemporalInstant> DisambiguatePossibleInstants( MaybeHandle<JSTemporalInstant> DisambiguatePossibleInstants(
Isolate* isolate, Handle<FixedArray> possible_instants, Isolate* isolate, Handle<FixedArray> possible_instants,
Handle<JSReceiver> time_zone, Handle<Object> date_time_obj, Handle<JSReceiver> time_zone, Handle<Object> date_time_obj,
Disambiguation disambiguation, const char* method) { Disambiguation disambiguation, const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 1. Assert: dateTime has an [[InitializedTemporalDateTime]] internal slot. // 1. Assert: dateTime has an [[InitializedTemporalDateTime]] internal slot.
DCHECK(date_time_obj->IsJSTemporalPlainDateTime()); DCHECK(date_time_obj->IsJSTemporalPlainDateTime());
...@@ -1165,11 +1216,11 @@ MaybeHandle<JSTemporalInstant> DisambiguatePossibleInstants( ...@@ -1165,11 +1216,11 @@ MaybeHandle<JSTemporalInstant> DisambiguatePossibleInstants(
JSTemporalInstant); JSTemporalInstant);
// 10. Let offsetBefore be ? GetOffsetNanosecondsFor(timeZone, dayBefore). // 10. Let offsetBefore be ? GetOffsetNanosecondsFor(timeZone, dayBefore).
Maybe<int64_t> maybe_offset_before = Maybe<int64_t> maybe_offset_before =
GetOffsetNanosecondsFor(isolate, time_zone, day_before, method); GetOffsetNanosecondsFor(isolate, time_zone, day_before, method_name);
MAYBE_RETURN(maybe_offset_before, Handle<JSTemporalInstant>()); MAYBE_RETURN(maybe_offset_before, Handle<JSTemporalInstant>());
// 11. Let offsetAfter be ? GetOffsetNanosecondsFor(timeZone, dayAfter). // 11. Let offsetAfter be ? GetOffsetNanosecondsFor(timeZone, dayAfter).
Maybe<int64_t> maybe_offset_after = Maybe<int64_t> maybe_offset_after =
GetOffsetNanosecondsFor(isolate, time_zone, day_after, method); GetOffsetNanosecondsFor(isolate, time_zone, day_after, method_name);
MAYBE_RETURN(maybe_offset_after, Handle<JSTemporalInstant>()); MAYBE_RETURN(maybe_offset_after, Handle<JSTemporalInstant>());
// 12. Let nanoseconds be offsetAfter − offsetBefore. // 12. Let nanoseconds be offsetAfter − offsetBefore.
...@@ -1284,7 +1335,7 @@ MaybeHandle<JSTemporalInstant> DisambiguatePossibleInstants( ...@@ -1284,7 +1335,7 @@ MaybeHandle<JSTemporalInstant> DisambiguatePossibleInstants(
MaybeHandle<JSTemporalInstant> BuiltinTimeZoneGetInstantFor( MaybeHandle<JSTemporalInstant> BuiltinTimeZoneGetInstantFor(
Isolate* isolate, Handle<JSReceiver> time_zone, Isolate* isolate, Handle<JSReceiver> time_zone,
Handle<JSTemporalPlainDateTime> date_time, Disambiguation disambiguation, Handle<JSTemporalPlainDateTime> date_time, Disambiguation disambiguation,
const char* method) { const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 1. Assert: dateTime has an [[InitializedTemporalDateTime]] internal slot. // 1. Assert: dateTime has an [[InitializedTemporalDateTime]] internal slot.
// 2. Let possibleInstants be ? GetPossibleInstantsFor(timeZone, dateTime). // 2. Let possibleInstants be ? GetPossibleInstantsFor(timeZone, dateTime).
...@@ -1295,7 +1346,7 @@ MaybeHandle<JSTemporalInstant> BuiltinTimeZoneGetInstantFor( ...@@ -1295,7 +1346,7 @@ MaybeHandle<JSTemporalInstant> BuiltinTimeZoneGetInstantFor(
// 3. Return ? DisambiguatePossibleInstants(possibleInstants, timeZone, // 3. Return ? DisambiguatePossibleInstants(possibleInstants, timeZone,
// dateTime, disambiguation). // dateTime, disambiguation).
return DisambiguatePossibleInstants(isolate, possible_instants, time_zone, return DisambiguatePossibleInstants(isolate, possible_instants, time_zone,
date_time, disambiguation, method); date_time, disambiguation, method_name);
} }
} // namespace } // namespace
...@@ -1304,7 +1355,7 @@ namespace temporal { ...@@ -1304,7 +1355,7 @@ namespace temporal {
// #sec-temporal-totemporalcalendar // #sec-temporal-totemporalcalendar
MaybeHandle<JSReceiver> ToTemporalCalendar( MaybeHandle<JSReceiver> ToTemporalCalendar(
Isolate* isolate, Handle<Object> temporal_calendar_like, Isolate* isolate, Handle<Object> temporal_calendar_like,
const char* method) { const char* method_name) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
// 1.If Type(temporalCalendarLike) is Object, then // 1.If Type(temporalCalendarLike) is Object, then
if (temporal_calendar_like->IsJSReceiver()) { if (temporal_calendar_like->IsJSReceiver()) {
...@@ -1380,7 +1431,7 @@ namespace { ...@@ -1380,7 +1431,7 @@ namespace {
// #sec-temporal-totemporalcalendarwithisodefault // #sec-temporal-totemporalcalendarwithisodefault
MaybeHandle<JSReceiver> ToTemporalCalendarWithISODefault( MaybeHandle<JSReceiver> ToTemporalCalendarWithISODefault(
Isolate* isolate, Handle<Object> temporal_calendar_like, Isolate* isolate, Handle<Object> temporal_calendar_like,
const char* method) { const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 1. If temporalCalendarLike is undefined, then // 1. If temporalCalendarLike is undefined, then
...@@ -1389,7 +1440,8 @@ MaybeHandle<JSReceiver> ToTemporalCalendarWithISODefault( ...@@ -1389,7 +1440,8 @@ MaybeHandle<JSReceiver> ToTemporalCalendarWithISODefault(
return temporal::GetISO8601Calendar(isolate); return temporal::GetISO8601Calendar(isolate);
} }
// 2. Return ? ToTemporalCalendar(temporalCalendarLike). // 2. Return ? ToTemporalCalendar(temporalCalendarLike).
return temporal::ToTemporalCalendar(isolate, temporal_calendar_like, method); return temporal::ToTemporalCalendar(isolate, temporal_calendar_like,
method_name);
} }
} // namespace } // namespace
...@@ -1398,7 +1450,7 @@ namespace temporal { ...@@ -1398,7 +1450,7 @@ namespace temporal {
// #sec-temporal-totemporaltimezone // #sec-temporal-totemporaltimezone
MaybeHandle<JSReceiver> ToTemporalTimeZone( MaybeHandle<JSReceiver> ToTemporalTimeZone(
Isolate* isolate, Handle<Object> temporal_time_zone_like, Isolate* isolate, Handle<Object> temporal_time_zone_like,
const char* method) { const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
...@@ -1457,6 +1509,76 @@ MaybeHandle<JSReceiver> ToTemporalTimeZone( ...@@ -1457,6 +1509,76 @@ MaybeHandle<JSReceiver> ToTemporalTimeZone(
} // namespace temporal } // namespace temporal
namespace { namespace {
// #sec-temporal-systemdatetime
MaybeHandle<JSTemporalPlainDateTime> SystemDateTime(
Isolate* isolate, Handle<Object> temporal_time_zone_like,
Handle<Object> calendar_like, const char* method_name) {
TEMPORAL_ENTER_FUNC();
Handle<JSReceiver> time_zone;
// 1. 1. If temporalTimeZoneLike is undefined, then
if (temporal_time_zone_like->IsUndefined()) {
// a. Let timeZone be ! SystemTimeZone().
ASSIGN_RETURN_ON_EXCEPTION(isolate, time_zone, SystemTimeZone(isolate),
JSTemporalPlainDateTime);
} else {
// 2. Else,
// a. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
ASSIGN_RETURN_ON_EXCEPTION(
isolate, time_zone,
temporal::ToTemporalTimeZone(isolate, temporal_time_zone_like,
method_name),
JSTemporalPlainDateTime);
}
Handle<JSReceiver> calendar;
// 3. Let calendar be ? ToTemporalCalendar(calendarLike).
ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar,
temporal::ToTemporalCalendar(isolate, calendar_like, method_name),
JSTemporalPlainDateTime);
// 4. Let instant be ! SystemInstant().
Handle<JSTemporalInstant> instant;
ASSIGN_RETURN_ON_EXCEPTION(isolate, instant, SystemInstant(isolate),
JSTemporalPlainDateTime);
// 5. Return ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant,
// calendar).
return temporal::BuiltinTimeZoneGetPlainDateTimeFor(
isolate, time_zone, instant, calendar, method_name);
}
MaybeHandle<JSTemporalZonedDateTime> SystemZonedDateTime(
Isolate* isolate, Handle<Object> temporal_time_zone_like,
Handle<Object> calendar_like, const char* method_name) {
TEMPORAL_ENTER_FUNC();
Handle<JSReceiver> time_zone;
// 1. 1. If temporalTimeZoneLike is undefined, then
if (temporal_time_zone_like->IsUndefined()) {
// a. Let timeZone be ! SystemTimeZone().
ASSIGN_RETURN_ON_EXCEPTION(isolate, time_zone, SystemTimeZone(isolate),
JSTemporalZonedDateTime);
} else {
// 2. Else,
// a. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
ASSIGN_RETURN_ON_EXCEPTION(
isolate, time_zone,
temporal::ToTemporalTimeZone(isolate, temporal_time_zone_like,
method_name),
JSTemporalZonedDateTime);
}
Handle<JSReceiver> calendar;
// 3. Let calendar be ? ToTemporalCalendar(calendarLike).
ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar,
temporal::ToTemporalCalendar(isolate, calendar_like, method_name),
JSTemporalZonedDateTime);
// 4. Let ns be ! SystemUTCEpochNanoseconds().
Handle<BigInt> ns;
ASSIGN_RETURN_ON_EXCEPTION(isolate, ns, SystemUTCEpochNanoseconds(isolate),
JSTemporalZonedDateTime);
// Return ? CreateTemporalZonedDateTime(ns, timeZone, calendar).
return CreateTemporalZonedDateTime(isolate, ns, time_zone, calendar);
}
#define COMPARE_RESULT_TO_SIGN(r) \ #define COMPARE_RESULT_TO_SIGN(r) \
((r) == ComparisonResult::kEqual \ ((r) == ComparisonResult::kEqual \
...@@ -1524,11 +1646,11 @@ MaybeHandle<String> FormatTimeZoneOffsetString(Isolate* isolate, ...@@ -1524,11 +1646,11 @@ MaybeHandle<String> FormatTimeZoneOffsetString(Isolate* isolate,
// #sec-temporal-builtintimezonegetoffsetstringfor // #sec-temporal-builtintimezonegetoffsetstringfor
MaybeHandle<String> BuiltinTimeZoneGetOffsetStringFor( MaybeHandle<String> BuiltinTimeZoneGetOffsetStringFor(
Isolate* isolate, Handle<JSReceiver> time_zone, Isolate* isolate, Handle<JSReceiver> time_zone,
Handle<JSTemporalInstant> instant, const char* method) { Handle<JSTemporalInstant> instant, const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 1. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant). // 1. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant).
Maybe<int64_t> maybe_offset_nanoseconds = Maybe<int64_t> maybe_offset_nanoseconds =
GetOffsetNanosecondsFor(isolate, time_zone, instant, method); GetOffsetNanosecondsFor(isolate, time_zone, instant, method_name);
MAYBE_RETURN(maybe_offset_nanoseconds, Handle<String>()); MAYBE_RETURN(maybe_offset_nanoseconds, Handle<String>());
int64_t offset_nanoseconds = maybe_offset_nanoseconds.FromJust(); int64_t offset_nanoseconds = maybe_offset_nanoseconds.FromJust();
...@@ -1859,7 +1981,7 @@ MaybeHandle<JSTemporalDuration> CalendarDateUntil( ...@@ -1859,7 +1981,7 @@ MaybeHandle<JSTemporalDuration> CalendarDateUntil(
Maybe<int64_t> GetOffsetNanosecondsFor(Isolate* isolate, Maybe<int64_t> GetOffsetNanosecondsFor(Isolate* isolate,
Handle<JSReceiver> time_zone_obj, Handle<JSReceiver> time_zone_obj,
Handle<Object> instant, Handle<Object> instant,
const char* method) { const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 1. Let getOffsetNanosecondsFor be ? GetMethod(timeZone, // 1. Let getOffsetNanosecondsFor be ? GetMethod(timeZone,
// "getOffsetNanosecondsFor"). // "getOffsetNanosecondsFor").
...@@ -2389,13 +2511,13 @@ Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours, ...@@ -2389,13 +2511,13 @@ Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours,
int64_t* minutes, int64_t* seconds, int64_t* minutes, int64_t* seconds,
int64_t* milliseconds, int64_t* microseconds, int64_t* milliseconds, int64_t* microseconds,
int64_t* nanoseconds, Unit largest_unit, int64_t* nanoseconds, Unit largest_unit,
const char* method) { const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 1. If relativeTo is not present, set relativeTo to undefined. // 1. If relativeTo is not present, set relativeTo to undefined.
return BalanceDuration(isolate, days, hours, minutes, seconds, milliseconds, return BalanceDuration(isolate, days, hours, minutes, seconds, milliseconds,
microseconds, nanoseconds, largest_unit, microseconds, nanoseconds, largest_unit,
isolate->factory()->undefined_value(), method); isolate->factory()->undefined_value(), method_name);
} }
Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours, Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours,
...@@ -2403,7 +2525,7 @@ Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours, ...@@ -2403,7 +2525,7 @@ Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours,
int64_t* milliseconds, int64_t* microseconds, int64_t* milliseconds, int64_t* microseconds,
int64_t* nanoseconds, Unit largest_unit, int64_t* nanoseconds, Unit largest_unit,
Handle<Object> relative_to_obj, Handle<Object> relative_to_obj,
const char* method) { const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 2. If Type(relativeTo) is Object and relativeTo has an // 2. If Type(relativeTo) is Object and relativeTo has an
...@@ -2423,7 +2545,7 @@ Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours, ...@@ -2423,7 +2545,7 @@ Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours,
Handle<JSReceiver>(relative_to->calendar(), isolate), Handle<JSReceiver>(relative_to->calendar(), isolate),
{0, 0, 0, *days, *hours, *minutes, *seconds, {0, 0, 0, *days, *hours, *minutes, *seconds,
*milliseconds, *microseconds, *nanoseconds}, *milliseconds, *microseconds, *nanoseconds},
method), method_name),
Nothing<bool>()); Nothing<bool>());
// b. Set nanoseconds to endNs − relativeTo.[[Nanoseconds]]. // b. Set nanoseconds to endNs − relativeTo.[[Nanoseconds]].
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
...@@ -2447,7 +2569,7 @@ Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours, ...@@ -2447,7 +2569,7 @@ Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours,
// a. Let result be ? NanosecondsToDays(nanoseconds, relativeTo). // a. Let result be ? NanosecondsToDays(nanoseconds, relativeTo).
Maybe<bool> maybe_result = Maybe<bool> maybe_result =
NanosecondsToDays(isolate, *nanoseconds, relative_to_obj, days, NanosecondsToDays(isolate, *nanoseconds, relative_to_obj, days,
nanoseconds, &result_day_length, method); nanoseconds, &result_day_length, method_name);
MAYBE_RETURN(maybe_result, Nothing<bool>()); MAYBE_RETURN(maybe_result, Nothing<bool>());
DCHECK(maybe_result.FromJust()); DCHECK(maybe_result.FromJust());
// b. Set days to result.[[Days]]. // b. Set days to result.[[Days]].
...@@ -2570,13 +2692,13 @@ MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate, ...@@ -2570,13 +2692,13 @@ MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate,
Handle<JSReceiver> time_zone, Handle<JSReceiver> time_zone,
Handle<JSReceiver> calendar, Handle<JSReceiver> calendar,
const DurationRecord& duration, const DurationRecord& duration,
const char* method) { const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 1. If options is not present, set options to ! OrdinaryObjectCreate(null). // 1. If options is not present, set options to ! OrdinaryObjectCreate(null).
Handle<JSReceiver> options = isolate->factory()->NewJSObjectWithNullProto(); Handle<JSReceiver> options = isolate->factory()->NewJSObjectWithNullProto();
return AddZonedDateTime(isolate, epoch_nanoseconds, time_zone, calendar, return AddZonedDateTime(isolate, epoch_nanoseconds, time_zone, calendar,
duration, options, method); duration, options, method_name);
} }
// #sec-temporal-addzoneddatetime // #sec-temporal-addzoneddatetime
...@@ -2586,7 +2708,7 @@ MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate, ...@@ -2586,7 +2708,7 @@ MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate,
Handle<JSReceiver> calendar, Handle<JSReceiver> calendar,
const DurationRecord& duration, const DurationRecord& duration,
Handle<JSReceiver> options, Handle<JSReceiver> options,
const char* method) { const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 2. If all of years, months, weeks, and days are 0, then // 2. If all of years, months, weeks, and days are 0, then
...@@ -2607,10 +2729,11 @@ MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate, ...@@ -2607,10 +2729,11 @@ MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate,
// 4. Let temporalDateTime be ? // 4. Let temporalDateTime be ?
// BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
Handle<JSTemporalPlainDateTime> temporal_date_time; Handle<JSTemporalPlainDateTime> temporal_date_time;
ASSIGN_RETURN_ON_EXCEPTION(isolate, temporal_date_time, ASSIGN_RETURN_ON_EXCEPTION(
temporal::BuiltinTimeZoneGetPlainDateTimeFor( isolate, temporal_date_time,
isolate, time_zone, instant, calendar, method), temporal::BuiltinTimeZoneGetPlainDateTimeFor(isolate, time_zone, instant,
BigInt); calendar, method_name),
BigInt);
// 5. Let datePart be ? CreateTemporalDate(temporalDateTime.[[ISOYear]], // 5. Let datePart be ? CreateTemporalDate(temporalDateTime.[[ISOYear]],
// temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], calendar). // temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], calendar).
Handle<JSTemporalPlainDate> date_part; Handle<JSTemporalPlainDate> date_part;
...@@ -2658,7 +2781,7 @@ MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate, ...@@ -2658,7 +2781,7 @@ MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate,
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, intermediate_instant, isolate, intermediate_instant,
BuiltinTimeZoneGetInstantFor(isolate, time_zone, intermediate_date_time, BuiltinTimeZoneGetInstantFor(isolate, time_zone, intermediate_date_time,
Disambiguation::kCompatible, method), Disambiguation::kCompatible, method_name),
BigInt); BigInt);
// 10. Return ! AddInstant(intermediateInstant.[[Nanoseconds]], hours, // 10. Return ! AddInstant(intermediateInstant.[[Nanoseconds]], hours,
// minutes, seconds, milliseconds, microseconds, nanoseconds). // minutes, seconds, milliseconds, microseconds, nanoseconds).
...@@ -2672,16 +2795,18 @@ MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate, ...@@ -2672,16 +2795,18 @@ MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate,
Maybe<bool> NanosecondsToDays(Isolate* isolate, int64_t nanoseconds, Maybe<bool> NanosecondsToDays(Isolate* isolate, int64_t nanoseconds,
Handle<Object> relative_to_obj, Handle<Object> relative_to_obj,
int64_t* result_days, int64_t* result_nanoseconds, int64_t* result_days, int64_t* result_nanoseconds,
int64_t* result_day_length, const char* method) { int64_t* result_day_length,
const char* method_name) {
return NanosecondsToDays(isolate, BigInt::FromInt64(isolate, nanoseconds), return NanosecondsToDays(isolate, BigInt::FromInt64(isolate, nanoseconds),
relative_to_obj, result_days, result_nanoseconds, relative_to_obj, result_days, result_nanoseconds,
result_day_length, method); result_day_length, method_name);
} }
Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds, Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds,
Handle<Object> relative_to_obj, Handle<Object> relative_to_obj,
int64_t* result_days, int64_t* result_nanoseconds, int64_t* result_days, int64_t* result_nanoseconds,
int64_t* result_day_length, const char* method) { int64_t* result_day_length,
const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
// 1. Assert: Type(nanoseconds) is BigInt. // 1. Assert: Type(nanoseconds) is BigInt.
...@@ -2749,7 +2874,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds, ...@@ -2749,7 +2874,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds,
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, start_date_time, isolate, start_date_time,
temporal::BuiltinTimeZoneGetPlainDateTimeFor( temporal::BuiltinTimeZoneGetPlainDateTimeFor(
isolate, time_zone, start_instant, calendar, method), isolate, time_zone, start_instant, calendar, method_name),
Nothing<bool>()); Nothing<bool>());
// 10. Let endNs be startNs + nanoseconds. // 10. Let endNs be startNs + nanoseconds.
...@@ -2770,7 +2895,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds, ...@@ -2770,7 +2895,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds,
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, end_date_time, isolate, end_date_time,
temporal::BuiltinTimeZoneGetPlainDateTimeFor( temporal::BuiltinTimeZoneGetPlainDateTimeFor(
isolate, time_zone, end_instant, calendar, method), isolate, time_zone, end_instant, calendar, method_name),
Nothing<bool>()); Nothing<bool>());
// 13. Let dateDifference be ? // 13. Let dateDifference be ?
...@@ -2794,7 +2919,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds, ...@@ -2794,7 +2919,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds,
end_date_time->iso_hour(), end_date_time->iso_minute(), end_date_time->iso_hour(), end_date_time->iso_minute(),
end_date_time->iso_second(), end_date_time->iso_millisecond(), end_date_time->iso_second(), end_date_time->iso_millisecond(),
end_date_time->iso_microsecond(), end_date_time->iso_nanosecond(), end_date_time->iso_microsecond(), end_date_time->iso_nanosecond(),
calendar, Unit::kDay, relative_to, method); calendar, Unit::kDay, relative_to, method_name);
MAYBE_RETURN(maybe_date_difference, Nothing<bool>()); MAYBE_RETURN(maybe_date_difference, Nothing<bool>());
DurationRecord date_difference = maybe_date_difference.FromJust(); DurationRecord date_difference = maybe_date_difference.FromJust();
...@@ -2808,7 +2933,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds, ...@@ -2808,7 +2933,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds,
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, intermediate_ns, isolate, intermediate_ns,
AddZonedDateTime(isolate, start_ns, time_zone, calendar, AddZonedDateTime(isolate, start_ns, time_zone, calendar,
{0, 0, 0, days, 0, 0, 0, 0, 0, 0}, method), {0, 0, 0, days, 0, 0, 0, 0, 0, 0}, method_name),
Nothing<bool>()); Nothing<bool>());
// 16. If sign is 1, then // 16. If sign is 1, then
...@@ -2824,7 +2949,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds, ...@@ -2824,7 +2949,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds,
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, intermediate_ns, isolate, intermediate_ns,
AddZonedDateTime(isolate, start_ns, time_zone, calendar, AddZonedDateTime(isolate, start_ns, time_zone, calendar,
{0, 0, 0, days, 0, 0, 0, 0, 0, 0}, method), {0, 0, 0, days, 0, 0, 0, 0, 0, 0}, method_name),
Nothing<bool>()); Nothing<bool>());
} }
} }
...@@ -2846,7 +2971,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds, ...@@ -2846,7 +2971,7 @@ Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds,
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, one_day_farther_ns, isolate, one_day_farther_ns,
AddZonedDateTime(isolate, intermediate_ns, time_zone, calendar, AddZonedDateTime(isolate, intermediate_ns, time_zone, calendar,
{0, 0, 0, sign, 0, 0, 0, 0, 0, 0}, method), {0, 0, 0, sign, 0, 0, 0, 0, 0, 0}, method_name),
Nothing<bool>()); Nothing<bool>());
// b. Set dayLengthNs to oneDayFartherNs − intermediateNs. // b. Set dayLengthNs to oneDayFartherNs − intermediateNs.
...@@ -2890,7 +3015,7 @@ Maybe<DurationRecord> DifferenceISODateTime( ...@@ -2890,7 +3015,7 @@ Maybe<DurationRecord> DifferenceISODateTime(
int32_t min1, int32_t s1, int32_t ms1, int32_t mus1, int32_t ns1, int32_t min1, int32_t s1, int32_t ms1, int32_t mus1, int32_t ns1,
int32_t y2, int32_t mon2, int32_t d2, int32_t h2, int32_t min2, int32_t s2, int32_t y2, int32_t mon2, int32_t d2, int32_t h2, int32_t min2, int32_t s2,
int32_t ms2, int32_t mus2, int32_t ns2, Handle<JSReceiver> calendar, int32_t ms2, int32_t mus2, int32_t ns2, Handle<JSReceiver> calendar,
Unit largest_unit, Handle<Object> options_obj, const char* method) { Unit largest_unit, Handle<Object> options_obj, const char* method_name) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
...@@ -2953,7 +3078,7 @@ Maybe<DurationRecord> DifferenceISODateTime( ...@@ -2953,7 +3078,7 @@ Maybe<DurationRecord> DifferenceISODateTime(
Maybe<bool> maybe_time_difference = BalanceDuration( Maybe<bool> maybe_time_difference = BalanceDuration(
isolate, &(result.days), &(result.hours), &(result.minutes), isolate, &(result.days), &(result.hours), &(result.minutes),
&(result.seconds), &(result.milliseconds), &(result.microseconds), &(result.seconds), &(result.milliseconds), &(result.microseconds),
&(result.nanoseconds), largest_unit, method); &(result.nanoseconds), largest_unit, method_name);
MAYBE_RETURN(maybe_time_difference, Nothing<DurationRecord>()); MAYBE_RETURN(maybe_time_difference, Nothing<DurationRecord>());
DCHECK(maybe_time_difference.FromJust()); DCHECK(maybe_time_difference.FromJust());
} }
...@@ -2997,7 +3122,7 @@ Maybe<DurationRecord> DifferenceISODateTime( ...@@ -2997,7 +3122,7 @@ Maybe<DurationRecord> DifferenceISODateTime(
Maybe<bool> maybe_balance_result = BalanceDuration( Maybe<bool> maybe_balance_result = BalanceDuration(
isolate, &(result.days), &(result.hours), &(result.minutes), isolate, &(result.days), &(result.hours), &(result.minutes),
&(result.seconds), &(result.milliseconds), &(result.microseconds), &(result.seconds), &(result.milliseconds), &(result.microseconds),
&(result.nanoseconds), largest_unit, method); &(result.nanoseconds), largest_unit, method_name);
MAYBE_RETURN(maybe_balance_result, Nothing<DurationRecord>()); MAYBE_RETURN(maybe_balance_result, Nothing<DurationRecord>());
DCHECK(maybe_balance_result.FromJust()); DCHECK(maybe_balance_result.FromJust());
// 14. Return the Record { [[Years]]: dateDifference.[[Years]], [[Months]]: // 14. Return the Record { [[Years]]: dateDifference.[[Years]], [[Months]]:
...@@ -3485,15 +3610,15 @@ MaybeHandle<JSTemporalDuration> JSTemporalDuration::Constructor( ...@@ -3485,15 +3610,15 @@ MaybeHandle<JSTemporalDuration> JSTemporalDuration::Constructor(
Handle<Object> days, Handle<Object> hours, Handle<Object> minutes, Handle<Object> days, Handle<Object> hours, Handle<Object> minutes,
Handle<Object> seconds, Handle<Object> milliseconds, Handle<Object> seconds, Handle<Object> milliseconds,
Handle<Object> microseconds, Handle<Object> nanoseconds) { Handle<Object> microseconds, Handle<Object> nanoseconds) {
const char* method = "Temporal.Duration"; const char* method_name = "Temporal.Duration";
// 1. If NewTarget is undefined, then // 1. If NewTarget is undefined, then
if (new_target->IsUndefined()) { if (new_target->IsUndefined()) {
// a. Throw a TypeError exception. // a. Throw a TypeError exception.
THROW_NEW_ERROR( THROW_NEW_ERROR(isolate,
isolate, NewTypeError(MessageTemplate::kMethodInvokedOnWrongType,
NewTypeError(MessageTemplate::kMethodInvokedOnWrongType, isolate->factory()->NewStringFromAsciiChecked(
isolate->factory()->NewStringFromAsciiChecked(method)), method_name)),
JSTemporalDuration); JSTemporalDuration);
} }
// 2. Let y be ? ToIntegerThrowOnInfinity(years). // 2. Let y be ? ToIntegerThrowOnInfinity(years).
Handle<Object> number_years; Handle<Object> number_years;
...@@ -3649,10 +3774,16 @@ MaybeHandle<JSTemporalCalendar> JSTemporalCalendar::Constructor( ...@@ -3649,10 +3774,16 @@ MaybeHandle<JSTemporalCalendar> JSTemporalCalendar::Constructor(
// #sec-temporal.calendar.prototype.tostring // #sec-temporal.calendar.prototype.tostring
MaybeHandle<String> JSTemporalCalendar::ToString( MaybeHandle<String> JSTemporalCalendar::ToString(
Isolate* isolate, Handle<JSTemporalCalendar> calendar, const char* method) { Isolate* isolate, Handle<JSTemporalCalendar> calendar,
const char* method_name) {
return CalendarIdentifier(isolate, calendar->calendar_index()); return CalendarIdentifier(isolate, calendar->calendar_index());
} }
// #sec-temporal.now.timezone
MaybeHandle<JSTemporalTimeZone> JSTemporalTimeZone::Now(Isolate* isolate) {
return SystemTimeZone(isolate);
}
// #sec-temporal.timezone // #sec-temporal.timezone
MaybeHandle<JSTemporalTimeZone> JSTemporalTimeZone::Constructor( MaybeHandle<JSTemporalTimeZone> JSTemporalTimeZone::Constructor(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target, Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
...@@ -3711,7 +3842,7 @@ MaybeHandle<JSTemporalTimeZone> JSTemporalTimeZone::Constructor( ...@@ -3711,7 +3842,7 @@ MaybeHandle<JSTemporalTimeZone> JSTemporalTimeZone::Constructor(
// #sec-temporal.timezone.prototype.tostring // #sec-temporal.timezone.prototype.tostring
MaybeHandle<Object> JSTemporalTimeZone::ToString( MaybeHandle<Object> JSTemporalTimeZone::ToString(
Isolate* isolate, Handle<JSTemporalTimeZone> time_zone, Isolate* isolate, Handle<JSTemporalTimeZone> time_zone,
const char* method) { const char* method_name) {
return time_zone->id(isolate); return time_zone->id(isolate);
} }
...@@ -3749,14 +3880,14 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Constructor( ...@@ -3749,14 +3880,14 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Constructor(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target, Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
Handle<Object> iso_year_obj, Handle<Object> iso_month_obj, Handle<Object> iso_year_obj, Handle<Object> iso_month_obj,
Handle<Object> iso_day_obj, Handle<Object> calendar_like) { Handle<Object> iso_day_obj, Handle<Object> calendar_like) {
const char* method = "Temporal.PlainDate"; const char* method_name = "Temporal.PlainDate";
// 1. If NewTarget is undefined, throw a TypeError exception. // 1. If NewTarget is undefined, throw a TypeError exception.
if (new_target->IsUndefined()) { if (new_target->IsUndefined()) {
THROW_NEW_ERROR( THROW_NEW_ERROR(isolate,
isolate, NewTypeError(MessageTemplate::kMethodInvokedOnWrongType,
NewTypeError(MessageTemplate::kMethodInvokedOnWrongType, isolate->factory()->NewStringFromAsciiChecked(
isolate->factory()->NewStringFromAsciiChecked(method)), method_name)),
JSTemporalPlainDate); JSTemporalPlainDate);
} }
#define TO_INT_THROW_ON_INFTY(name, T) \ #define TO_INT_THROW_ON_INFTY(name, T) \
int32_t name; \ int32_t name; \
...@@ -3777,7 +3908,7 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Constructor( ...@@ -3777,7 +3908,7 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Constructor(
Handle<JSReceiver> calendar; Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar, isolate, calendar,
ToTemporalCalendarWithISODefault(isolate, calendar_like, method), ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
JSTemporalPlainDate); JSTemporalPlainDate);
// 9. Return ? CreateTemporalDate(y, m, d, calendar, NewTarget). // 9. Return ? CreateTemporalDate(y, m, d, calendar, NewTarget).
...@@ -3789,7 +3920,7 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Constructor( ...@@ -3789,7 +3920,7 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Constructor(
MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::WithCalendar( MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::WithCalendar(
Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date, Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date,
Handle<Object> calendar_like) { Handle<Object> calendar_like) {
const char* method = "Temporal.PlainDate.prototype.withCalendar"; const char* method_name = "Temporal.PlainDate.prototype.withCalendar";
// 1. Let temporalDate be the this value. // 1. Let temporalDate be the this value.
// 2. Perform ? RequireInternalSlot(temporalDate, // 2. Perform ? RequireInternalSlot(temporalDate,
// [[InitializedTemporalDate]]). // [[InitializedTemporalDate]]).
...@@ -3797,7 +3928,7 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::WithCalendar( ...@@ -3797,7 +3928,7 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::WithCalendar(
Handle<JSReceiver> calendar; Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar, isolate, calendar,
temporal::ToTemporalCalendar(isolate, calendar_like, method), temporal::ToTemporalCalendar(isolate, calendar_like, method_name),
JSTemporalPlainDate); JSTemporalPlainDate);
// 4. Return ? CreateTemporalDate(temporalDate.[[ISOYear]], // 4. Return ? CreateTemporalDate(temporalDate.[[ISOYear]],
// temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], calendar). // temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], calendar).
...@@ -3806,6 +3937,46 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::WithCalendar( ...@@ -3806,6 +3937,46 @@ MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::WithCalendar(
temporal_date->iso_day(), calendar); temporal_date->iso_day(), calendar);
} }
// #sec-temporal.now.plaindate
MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::Now(
Isolate* isolate, Handle<Object> calendar_like,
Handle<Object> temporal_time_zone_like) {
const char* method_name = "Temporal.Now.plainDate";
// 1. Let dateTime be ? SystemDateTime(temporalTimeZoneLike, calendarLike).
Handle<JSTemporalPlainDateTime> date_time;
ASSIGN_RETURN_ON_EXCEPTION(isolate, date_time,
SystemDateTime(isolate, temporal_time_zone_like,
calendar_like, method_name),
JSTemporalPlainDate);
// 2. Return ! CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]],
// dateTime.[[ISODay]], dateTime.[[Calendar]]).
return CreateTemporalDate(isolate, date_time->iso_year(),
date_time->iso_month(), date_time->iso_day(),
Handle<JSReceiver>(date_time->calendar(), isolate));
}
// #sec-temporal.now.plaindateiso
MaybeHandle<JSTemporalPlainDate> JSTemporalPlainDate::NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like) {
const char* method_name = "Temporal.Now.plainDateISO";
// 1. Let calendar be ! GetISO8601Calendar().
Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
temporal::GetISO8601Calendar(isolate),
JSTemporalPlainDate);
// 2. Let dateTime be ? SystemDateTime(temporalTimeZoneLike, calendar).
Handle<JSTemporalPlainDateTime> date_time;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, date_time,
SystemDateTime(isolate, temporal_time_zone_like, calendar, method_name),
JSTemporalPlainDate);
// 3. Return ! CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]],
// dateTime.[[ISODay]], dateTime.[[Calendar]]).
return CreateTemporalDate(isolate, date_time->iso_year(),
date_time->iso_month(), date_time->iso_day(),
Handle<JSReceiver>(date_time->calendar(), isolate));
}
#define DEFINE_INT_FIELD(obj, str, field, item) \ #define DEFINE_INT_FIELD(obj, str, field, item) \
CHECK(JSReceiver::CreateDataProperty( \ CHECK(JSReceiver::CreateDataProperty( \
isolate, obj, factory->str##_string(), \ isolate, obj, factory->str##_string(), \
...@@ -3851,14 +4022,14 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Constructor( ...@@ -3851,14 +4022,14 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Constructor(
Handle<Object> minute_obj, Handle<Object> second_obj, Handle<Object> minute_obj, Handle<Object> second_obj,
Handle<Object> millisecond_obj, Handle<Object> microsecond_obj, Handle<Object> millisecond_obj, Handle<Object> microsecond_obj,
Handle<Object> nanosecond_obj, Handle<Object> calendar_like) { Handle<Object> nanosecond_obj, Handle<Object> calendar_like) {
const char* method = "Temporal.PlainDateTime"; const char* method_name = "Temporal.PlainDateTime";
// 1. If NewTarget is undefined, throw a TypeError exception. // 1. If NewTarget is undefined, throw a TypeError exception.
if (new_target->IsUndefined()) { if (new_target->IsUndefined()) {
THROW_NEW_ERROR( THROW_NEW_ERROR(isolate,
isolate, NewTypeError(MessageTemplate::kMethodInvokedOnWrongType,
NewTypeError(MessageTemplate::kMethodInvokedOnWrongType, isolate->factory()->NewStringFromAsciiChecked(
isolate->factory()->NewStringFromAsciiChecked(method)), method_name)),
JSTemporalPlainDateTime); JSTemporalPlainDateTime);
} }
TO_INT_THROW_ON_INFTY(iso_year, JSTemporalPlainDateTime); TO_INT_THROW_ON_INFTY(iso_year, JSTemporalPlainDateTime);
...@@ -3875,7 +4046,7 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Constructor( ...@@ -3875,7 +4046,7 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Constructor(
Handle<JSReceiver> calendar; Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar, isolate, calendar,
ToTemporalCalendarWithISODefault(isolate, calendar_like, method), ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
JSTemporalPlainDateTime); JSTemporalPlainDateTime);
// 21. Return ? CreateTemporalDateTime(isoYear, isoMonth, isoDay, hour, // 21. Return ? CreateTemporalDateTime(isoYear, isoMonth, isoDay, hour,
...@@ -3889,7 +4060,7 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Constructor( ...@@ -3889,7 +4060,7 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Constructor(
MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::WithCalendar( MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::WithCalendar(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time, Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time,
Handle<Object> calendar_like) { Handle<Object> calendar_like) {
const char* method = "Temporal.PlainDateTime.prototype.withCalendar"; const char* method_name = "Temporal.PlainDateTime.prototype.withCalendar";
// 1. Let temporalDateTime be the this value. // 1. Let temporalDateTime be the this value.
// 2. Perform ? RequireInternalSlot(temporalDateTime, // 2. Perform ? RequireInternalSlot(temporalDateTime,
// [[InitializedTemporalDateTime]]). // [[InitializedTemporalDateTime]]).
...@@ -3897,7 +4068,7 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::WithCalendar( ...@@ -3897,7 +4068,7 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::WithCalendar(
Handle<JSReceiver> calendar; Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar, isolate, calendar,
temporal::ToTemporalCalendar(isolate, calendar_like, method), temporal::ToTemporalCalendar(isolate, calendar_like, method_name),
JSTemporalPlainDateTime); JSTemporalPlainDateTime);
// 4. Return ? CreateTemporalDateTime(temporalDateTime.[[ISOYear]], // 4. Return ? CreateTemporalDateTime(temporalDateTime.[[ISOYear]],
// temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], // temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]],
...@@ -3912,6 +4083,30 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::WithCalendar( ...@@ -3912,6 +4083,30 @@ MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::WithCalendar(
date_time->iso_microsecond(), date_time->iso_nanosecond(), calendar); date_time->iso_microsecond(), date_time->iso_nanosecond(), calendar);
} }
// #sec-temporal.now.plaindatetime
MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::Now(
Isolate* isolate, Handle<Object> calendar_like,
Handle<Object> temporal_time_zone_like) {
const char* method_name = "Temporal.Now.plainDateTime";
// 1. Return ? SystemDateTime(temporalTimeZoneLike, calendarLike).
return SystemDateTime(isolate, temporal_time_zone_like, calendar_like,
method_name);
}
// #sec-temporal.now.plaindatetimeiso
MaybeHandle<JSTemporalPlainDateTime> JSTemporalPlainDateTime::NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like) {
const char* method_name = "Temporal.Now.plainDateTimeISO";
// 1. Let calendar be ! GetISO8601Calendar().
Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
temporal::GetISO8601Calendar(isolate),
JSTemporalPlainDateTime);
// 2. Return ? SystemDateTime(temporalTimeZoneLike, calendar).
return SystemDateTime(isolate, temporal_time_zone_like, calendar,
method_name);
}
// #sec-temporal.plaindatetime.prototype.getisofields // #sec-temporal.plaindatetime.prototype.getisofields
MaybeHandle<JSReceiver> JSTemporalPlainDateTime::GetISOFields( MaybeHandle<JSReceiver> JSTemporalPlainDateTime::GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time) { Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time) {
...@@ -3965,14 +4160,14 @@ MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainMonthDay::Constructor( ...@@ -3965,14 +4160,14 @@ MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainMonthDay::Constructor(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target, Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
Handle<Object> iso_month_obj, Handle<Object> iso_day_obj, Handle<Object> iso_month_obj, Handle<Object> iso_day_obj,
Handle<Object> calendar_like, Handle<Object> reference_iso_year_obj) { Handle<Object> calendar_like, Handle<Object> reference_iso_year_obj) {
const char* method = "Temporal.PlainMonthDay"; const char* method_name = "Temporal.PlainMonthDay";
// 1. If NewTarget is undefined, throw a TypeError exception. // 1. If NewTarget is undefined, throw a TypeError exception.
if (new_target->IsUndefined()) { if (new_target->IsUndefined()) {
THROW_NEW_ERROR( THROW_NEW_ERROR(isolate,
isolate, NewTypeError(MessageTemplate::kMethodInvokedOnWrongType,
NewTypeError(MessageTemplate::kMethodInvokedOnWrongType, isolate->factory()->NewStringFromAsciiChecked(
isolate->factory()->NewStringFromAsciiChecked(method)), method_name)),
JSTemporalPlainMonthDay); JSTemporalPlainMonthDay);
} }
// 3. Let m be ? ToIntegerThrowOnInfinity(isoMonth). // 3. Let m be ? ToIntegerThrowOnInfinity(isoMonth).
...@@ -3983,7 +4178,7 @@ MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainMonthDay::Constructor( ...@@ -3983,7 +4178,7 @@ MaybeHandle<JSTemporalPlainMonthDay> JSTemporalPlainMonthDay::Constructor(
Handle<JSReceiver> calendar; Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar, isolate, calendar,
ToTemporalCalendarWithISODefault(isolate, calendar_like, method), ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
JSTemporalPlainMonthDay); JSTemporalPlainMonthDay);
// 2. If referenceISOYear is undefined, then // 2. If referenceISOYear is undefined, then
...@@ -4035,14 +4230,14 @@ MaybeHandle<JSTemporalPlainYearMonth> JSTemporalPlainYearMonth::Constructor( ...@@ -4035,14 +4230,14 @@ MaybeHandle<JSTemporalPlainYearMonth> JSTemporalPlainYearMonth::Constructor(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target, Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
Handle<Object> iso_year_obj, Handle<Object> iso_month_obj, Handle<Object> iso_year_obj, Handle<Object> iso_month_obj,
Handle<Object> calendar_like, Handle<Object> reference_iso_day_obj) { Handle<Object> calendar_like, Handle<Object> reference_iso_day_obj) {
const char* method = "Temporal.PlainYearMonth"; const char* method_name = "Temporal.PlainYearMonth";
// 1. If NewTarget is undefined, throw a TypeError exception. // 1. If NewTarget is undefined, throw a TypeError exception.
if (new_target->IsUndefined()) { if (new_target->IsUndefined()) {
THROW_NEW_ERROR( THROW_NEW_ERROR(isolate,
isolate, NewTypeError(MessageTemplate::kMethodInvokedOnWrongType,
NewTypeError(MessageTemplate::kMethodInvokedOnWrongType, isolate->factory()->NewStringFromAsciiChecked(
isolate->factory()->NewStringFromAsciiChecked(method)), method_name)),
JSTemporalPlainYearMonth); JSTemporalPlainYearMonth);
} }
// 7. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike). // 7. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
// 10. Return ? CreateTemporalYearMonth(y, m, calendar, ref, NewTarget). // 10. Return ? CreateTemporalYearMonth(y, m, calendar, ref, NewTarget).
...@@ -4055,7 +4250,7 @@ MaybeHandle<JSTemporalPlainYearMonth> JSTemporalPlainYearMonth::Constructor( ...@@ -4055,7 +4250,7 @@ MaybeHandle<JSTemporalPlainYearMonth> JSTemporalPlainYearMonth::Constructor(
Handle<JSReceiver> calendar; Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar, isolate, calendar,
ToTemporalCalendarWithISODefault(isolate, calendar_like, method), ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
JSTemporalPlainYearMonth); JSTemporalPlainYearMonth);
// 2. If referenceISODay is undefined, then // 2. If referenceISODay is undefined, then
...@@ -4109,16 +4304,16 @@ MaybeHandle<JSTemporalPlainTime> JSTemporalPlainTime::Constructor( ...@@ -4109,16 +4304,16 @@ MaybeHandle<JSTemporalPlainTime> JSTemporalPlainTime::Constructor(
Handle<Object> hour_obj, Handle<Object> minute_obj, Handle<Object> hour_obj, Handle<Object> minute_obj,
Handle<Object> second_obj, Handle<Object> millisecond_obj, Handle<Object> second_obj, Handle<Object> millisecond_obj,
Handle<Object> microsecond_obj, Handle<Object> nanosecond_obj) { Handle<Object> microsecond_obj, Handle<Object> nanosecond_obj) {
const char* method = "Temporal.PlainTime"; const char* method_name = "Temporal.PlainTime";
// 1. If NewTarget is undefined, then // 1. If NewTarget is undefined, then
// a. Throw a TypeError exception. // a. Throw a TypeError exception.
if (new_target->IsUndefined()) { if (new_target->IsUndefined()) {
// a. Throw a TypeError exception. // a. Throw a TypeError exception.
THROW_NEW_ERROR( THROW_NEW_ERROR(isolate,
isolate, NewTypeError(MessageTemplate::kMethodInvokedOnWrongType,
NewTypeError(MessageTemplate::kMethodInvokedOnWrongType, isolate->factory()->NewStringFromAsciiChecked(
isolate->factory()->NewStringFromAsciiChecked(method)), method_name)),
JSTemporalPlainTime); JSTemporalPlainTime);
} }
TO_INT_THROW_ON_INFTY(hour, JSTemporalPlainTime); TO_INT_THROW_ON_INFTY(hour, JSTemporalPlainTime);
...@@ -4134,6 +4329,31 @@ MaybeHandle<JSTemporalPlainTime> JSTemporalPlainTime::Constructor( ...@@ -4134,6 +4329,31 @@ MaybeHandle<JSTemporalPlainTime> JSTemporalPlainTime::Constructor(
millisecond, microsecond, nanosecond); millisecond, microsecond, nanosecond);
} }
// #sec-temporal.now.plaintimeiso
MaybeHandle<JSTemporalPlainTime> JSTemporalPlainTime::NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like) {
const char* method_name = "Temporal.Now.plainTimeISO";
// 1. Let calendar be ! GetISO8601Calendar().
Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
temporal::GetISO8601Calendar(isolate),
JSTemporalPlainTime);
// 2. Let dateTime be ? SystemDateTime(temporalTimeZoneLike, calendar).
Handle<JSTemporalPlainDateTime> date_time;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, date_time,
SystemDateTime(isolate, temporal_time_zone_like, calendar, method_name),
JSTemporalPlainTime);
// 3. Return ! CreateTemporalTime(dateTime.[[ISOHour]],
// dateTime.[[ISOMinute]], dateTime.[[ISOSecond]],
// dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]],
// dateTime.[[ISONanosecond]]).
return CreateTemporalTime(
isolate, date_time->iso_hour(), date_time->iso_minute(),
date_time->iso_second(), date_time->iso_millisecond(),
date_time->iso_microsecond(), date_time->iso_nanosecond());
}
// #sec-temporal.plaintime.prototype.getisofields // #sec-temporal.plaintime.prototype.getisofields
MaybeHandle<JSReceiver> JSTemporalPlainTime::GetISOFields( MaybeHandle<JSReceiver> JSTemporalPlainTime::GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainTime> temporal_time) { Isolate* isolate, Handle<JSTemporalPlainTime> temporal_time) {
...@@ -4182,15 +4402,15 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::Constructor( ...@@ -4182,15 +4402,15 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::Constructor(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target, Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
Handle<Object> epoch_nanoseconds_obj, Handle<Object> time_zone_like, Handle<Object> epoch_nanoseconds_obj, Handle<Object> time_zone_like,
Handle<Object> calendar_like) { Handle<Object> calendar_like) {
const char* method = "Temporal.ZonedDateTime"; const char* method_name = "Temporal.ZonedDateTime";
// 1. If NewTarget is undefined, then // 1. If NewTarget is undefined, then
if (new_target->IsUndefined()) { if (new_target->IsUndefined()) {
// a. Throw a TypeError exception. // a. Throw a TypeError exception.
THROW_NEW_ERROR( THROW_NEW_ERROR(isolate,
isolate, NewTypeError(MessageTemplate::kMethodInvokedOnWrongType,
NewTypeError(MessageTemplate::kMethodInvokedOnWrongType, isolate->factory()->NewStringFromAsciiChecked(
isolate->factory()->NewStringFromAsciiChecked(method)), method_name)),
JSTemporalZonedDateTime); JSTemporalZonedDateTime);
} }
// 2. Set epochNanoseconds to ? ToBigInt(epochNanoseconds). // 2. Set epochNanoseconds to ? ToBigInt(epochNanoseconds).
Handle<BigInt> epoch_nanoseconds; Handle<BigInt> epoch_nanoseconds;
...@@ -4208,14 +4428,14 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::Constructor( ...@@ -4208,14 +4428,14 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::Constructor(
Handle<JSReceiver> time_zone; Handle<JSReceiver> time_zone;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, time_zone, isolate, time_zone,
temporal::ToTemporalTimeZone(isolate, time_zone_like, method), temporal::ToTemporalTimeZone(isolate, time_zone_like, method_name),
JSTemporalZonedDateTime); JSTemporalZonedDateTime);
// 5. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike). // 5. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
Handle<JSReceiver> calendar; Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar, isolate, calendar,
ToTemporalCalendarWithISODefault(isolate, calendar_like, method), ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
JSTemporalZonedDateTime); JSTemporalZonedDateTime);
// 6. Return ? CreateTemporalZonedDateTime(epochNanoseconds, timeZone, // 6. Return ? CreateTemporalZonedDateTime(epochNanoseconds, timeZone,
...@@ -4229,7 +4449,7 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithCalendar( ...@@ -4229,7 +4449,7 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithCalendar(
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time, Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time,
Handle<Object> calendar_like) { Handle<Object> calendar_like) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
const char* method = "Temporal.ZonedDateTime.prototype.withCalendar"; const char* method_name = "Temporal.ZonedDateTime.prototype.withCalendar";
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, // 2. Perform ? RequireInternalSlot(zonedDateTime,
// [[InitializedTemporalZonedDateTime]]). // [[InitializedTemporalZonedDateTime]]).
...@@ -4237,7 +4457,7 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithCalendar( ...@@ -4237,7 +4457,7 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithCalendar(
Handle<JSReceiver> calendar; Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, calendar, isolate, calendar,
temporal::ToTemporalCalendar(isolate, calendar_like, method), temporal::ToTemporalCalendar(isolate, calendar_like, method_name),
JSTemporalZonedDateTime); JSTemporalZonedDateTime);
// 4. Return ? CreateTemporalZonedDateTime(zonedDateTime.[[Nanoseconds]], // 4. Return ? CreateTemporalZonedDateTime(zonedDateTime.[[Nanoseconds]],
...@@ -4252,7 +4472,7 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithTimeZone( ...@@ -4252,7 +4472,7 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithTimeZone(
Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time, Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time,
Handle<Object> time_zone_like) { Handle<Object> time_zone_like) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
const char* method = "Temporal.ZonedDateTime.prototype.withTimeZone"; const char* method_name = "Temporal.ZonedDateTime.prototype.withTimeZone";
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, // 2. Perform ? RequireInternalSlot(zonedDateTime,
// [[InitializedTemporalZonedDateTime]]). // [[InitializedTemporalZonedDateTime]]).
...@@ -4260,7 +4480,7 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithTimeZone( ...@@ -4260,7 +4480,7 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithTimeZone(
Handle<JSReceiver> time_zone; Handle<JSReceiver> time_zone;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, time_zone, isolate, time_zone,
temporal::ToTemporalTimeZone(isolate, time_zone_like, method), temporal::ToTemporalTimeZone(isolate, time_zone_like, method_name),
JSTemporalZonedDateTime); JSTemporalZonedDateTime);
// 4. Return ? CreateTemporalZonedDateTime(zonedDateTime.[[Nanoseconds]], // 4. Return ? CreateTemporalZonedDateTime(zonedDateTime.[[Nanoseconds]],
...@@ -4272,11 +4492,36 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithTimeZone( ...@@ -4272,11 +4492,36 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::WithTimeZone(
return CreateTemporalZonedDateTime(isolate, nanoseconds, time_zone, calendar); return CreateTemporalZonedDateTime(isolate, nanoseconds, time_zone, calendar);
} }
// #sec-temporal.now.zoneddatetime
MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::Now(
Isolate* isolate, Handle<Object> calendar_like,
Handle<Object> temporal_time_zone_like) {
const char* method_name = "Temporal.Now.zonedDateTime";
// 1. Return ? SystemZonedDateTime(temporalTimeZoneLike, calendarLike).
return SystemZonedDateTime(isolate, temporal_time_zone_like, calendar_like,
method_name);
}
// #sec-temporal.now.zoneddatetimeiso
MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::NowISO(
Isolate* isolate, Handle<Object> temporal_time_zone_like) {
TEMPORAL_ENTER_FUNC();
const char* method_name = "Temporal.Now.zonedDateTimeISO";
// 1. Let calendar be ! GetISO8601Calendar().
Handle<JSReceiver> calendar;
ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
temporal::GetISO8601Calendar(isolate),
JSTemporalZonedDateTime);
// 2. Return ? SystemZonedDateTime(temporalTimeZoneLike, calendar).
return SystemZonedDateTime(isolate, temporal_time_zone_like, calendar,
method_name);
}
// #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) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
const char* method = "Temporal.ZonedDateTime.prototype.getISOFields"; const char* method_name = "Temporal.ZonedDateTime.prototype.getISOFields";
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, // 2. Perform ? RequireInternalSlot(zonedDateTime,
...@@ -4301,16 +4546,17 @@ MaybeHandle<JSReceiver> JSTemporalZonedDateTime::GetISOFields( ...@@ -4301,16 +4546,17 @@ MaybeHandle<JSReceiver> JSTemporalZonedDateTime::GetISOFields(
// 7. Let dateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, // 7. Let dateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone,
// instant, calendar). // instant, calendar).
Handle<JSTemporalPlainDateTime> date_time; Handle<JSTemporalPlainDateTime> date_time;
ASSIGN_RETURN_ON_EXCEPTION(isolate, date_time,
temporal::BuiltinTimeZoneGetPlainDateTimeFor(
isolate, time_zone, instant, calendar, method),
JSReceiver);
// 8. Let offset be ? BuiltinTimeZoneGetOffsetStringFor(timeZone, instant).
Handle<String> offset;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate, offset, isolate, date_time,
BuiltinTimeZoneGetOffsetStringFor(isolate, time_zone, instant, method), temporal::BuiltinTimeZoneGetPlainDateTimeFor(isolate, time_zone, instant,
calendar, method_name),
JSReceiver); JSReceiver);
// 8. Let offset be ? BuiltinTimeZoneGetOffsetStringFor(timeZone, instant).
Handle<String> offset;
ASSIGN_RETURN_ON_EXCEPTION(isolate, offset,
BuiltinTimeZoneGetOffsetStringFor(
isolate, time_zone, instant, method_name),
JSReceiver);
#define DEFINE_STRING_FIELD(obj, str, field) \ #define DEFINE_STRING_FIELD(obj, str, field) \
CHECK(JSReceiver::CreateDataProperty(isolate, obj, factory->str##_string(), \ CHECK(JSReceiver::CreateDataProperty(isolate, obj, factory->str##_string(), \
...@@ -4354,20 +4600,26 @@ MaybeHandle<JSReceiver> JSTemporalZonedDateTime::GetISOFields( ...@@ -4354,20 +4600,26 @@ MaybeHandle<JSReceiver> JSTemporalZonedDateTime::GetISOFields(
return fields; return fields;
} }
// #sec-temporal.now.instant
MaybeHandle<JSTemporalInstant> JSTemporalInstant::Now(Isolate* isolate) {
TEMPORAL_ENTER_FUNC();
return SystemInstant(isolate);
}
// #sec-temporal.instant // #sec-temporal.instant
MaybeHandle<JSTemporalInstant> JSTemporalInstant::Constructor( MaybeHandle<JSTemporalInstant> JSTemporalInstant::Constructor(
Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target, Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
Handle<Object> epoch_nanoseconds_obj) { Handle<Object> epoch_nanoseconds_obj) {
TEMPORAL_ENTER_FUNC(); TEMPORAL_ENTER_FUNC();
const char* method = "Temporal.Instant"; const char* method_name = "Temporal.Instant";
// 1. If NewTarget is undefined, then // 1. If NewTarget is undefined, then
if (new_target->IsUndefined()) { if (new_target->IsUndefined()) {
// a. Throw a TypeError exception. // a. Throw a TypeError exception.
THROW_NEW_ERROR( THROW_NEW_ERROR(isolate,
isolate, NewTypeError(MessageTemplate::kMethodInvokedOnWrongType,
NewTypeError(MessageTemplate::kMethodInvokedOnWrongType, isolate->factory()->NewStringFromAsciiChecked(
isolate->factory()->NewStringFromAsciiChecked(method)), method_name)),
JSTemporalInstant); JSTemporalInstant);
} }
// 2. Let epochNanoseconds be ? ToBigInt(epochNanoseconds). // 2. Let epochNanoseconds be ? ToBigInt(epochNanoseconds).
Handle<BigInt> epoch_nanoseconds; Handle<BigInt> epoch_nanoseconds;
......
...@@ -99,6 +99,10 @@ class JSTemporalInstant ...@@ -99,6 +99,10 @@ class JSTemporalInstant
Isolate* isolate, Handle<JSFunction> target, Isolate* isolate, Handle<JSFunction> target,
Handle<HeapObject> new_target, Handle<Object> epoch_nanoseconds); 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) DECL_PRINTER(JSTemporalInstant)
TQ_OBJECT_CONSTRUCTORS(JSTemporalInstant) TQ_OBJECT_CONSTRUCTORS(JSTemporalInstant)
...@@ -123,6 +127,14 @@ class JSTemporalPlainDate ...@@ -123,6 +127,14 @@ class JSTemporalPlainDate
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields( V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainDate> plain_date); 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) DECL_PRINTER(JSTemporalPlainDate)
DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY() DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY()
...@@ -154,6 +166,15 @@ class JSTemporalPlainDateTime ...@@ -154,6 +166,15 @@ class JSTemporalPlainDateTime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields( V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time); 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) DECL_PRINTER(JSTemporalPlainDateTime)
DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY() DEFINE_TORQUE_GENERATED_JS_TEMPORAL_YEAR_MONTH_DAY()
...@@ -204,6 +225,10 @@ class JSTemporalPlainTime ...@@ -204,6 +225,10 @@ class JSTemporalPlainTime
V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields( V8_WARN_UNUSED_RESULT static MaybeHandle<JSReceiver> GetISOFields(
Isolate* isolate, Handle<JSTemporalPlainTime> plain_time); 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) DECL_PRINTER(JSTemporalPlainTime)
DEFINE_TORQUE_GENERATED_JS_TEMPORAL_HOUR_MINUTE_SECOND() DEFINE_TORQUE_GENERATED_JS_TEMPORAL_HOUR_MINUTE_SECOND()
...@@ -243,6 +268,10 @@ class JSTemporalPlainYearMonth ...@@ -243,6 +268,10 @@ class JSTemporalPlainYearMonth
class JSTemporalTimeZone class JSTemporalTimeZone
: public TorqueGeneratedJSTemporalTimeZone<JSTemporalTimeZone, JSObject> { : public TorqueGeneratedJSTemporalTimeZone<JSTemporalTimeZone, JSObject> {
public: public:
// #sec-temporal.now.timezone
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalTimeZone> Now(
Isolate* isolate);
// #sec-temporal.timezone // #sec-temporal.timezone
V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalTimeZone> Constructor( V8_WARN_UNUSED_RESULT static MaybeHandle<JSTemporalTimeZone> Constructor(
Isolate* isolate, Handle<JSFunction> target, Isolate* isolate, Handle<JSFunction> target,
...@@ -299,6 +328,15 @@ class JSTemporalZonedDateTime ...@@ -299,6 +328,15 @@ class JSTemporalZonedDateTime
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);
// #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) DECL_PRINTER(JSTemporalZonedDateTime)
TQ_OBJECT_CONSTRUCTORS(JSTemporalZonedDateTime) TQ_OBJECT_CONSTRUCTORS(JSTemporalZonedDateTime)
......
...@@ -79,7 +79,6 @@ ...@@ -79,7 +79,6 @@
'temporal/instant-subtract': [FAIL], 'temporal/instant-subtract': [FAIL],
'temporal/instant-to-json': [FAIL], 'temporal/instant-to-json': [FAIL],
'temporal/instant-toJSON': [FAIL], 'temporal/instant-toJSON': [FAIL],
'temporal/instant-valueOf': [FAIL],
'temporal/plain-date-add': [FAIL], 'temporal/plain-date-add': [FAIL],
'temporal/plain-date-compare': [FAIL], 'temporal/plain-date-compare': [FAIL],
'temporal/plain-date-equals': [FAIL], 'temporal/plain-date-equals': [FAIL],
......
...@@ -954,95 +954,20 @@ ...@@ -954,95 +954,20 @@
'built-ins/Temporal/Instant/prototype/until/smallestunit-plurals-accepted': [FAIL], '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-undefined': [FAIL],
'built-ins/Temporal/Instant/prototype/until/smallestunit-wrong-type': [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/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/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],
'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/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/timezone-string-datetime': [FAIL],
'built-ins/Temporal/Now/plainDateTimeISO/time-zone-undefined': [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/timezone-string-datetime': [FAIL],
'built-ins/Temporal/Now/plainDateTime/time-zone-undefined': [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/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/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-datetime': [FAIL],
'built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-multiple-offsets': [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-datetime': [FAIL],
'built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets': [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/basic': [FAIL],
'built-ins/Temporal/PlainDate/compare/argument-object': [FAIL], 'built-ins/Temporal/PlainDate/compare/argument-object': [FAIL],
'built-ins/Temporal/PlainDate/compare/argument-plaindatetime': [FAIL], 'built-ins/Temporal/PlainDate/compare/argument-plaindatetime': [FAIL],
...@@ -2438,8 +2363,6 @@ ...@@ -2438,8 +2363,6 @@
'intl402/Temporal/Instant/prototype/toLocaleString/options-conflict': [FAIL], 'intl402/Temporal/Instant/prototype/toLocaleString/options-conflict': [FAIL],
'intl402/Temporal/Instant/prototype/toLocaleString/options-undefined': [FAIL], 'intl402/Temporal/Instant/prototype/toLocaleString/options-undefined': [FAIL],
'intl402/Temporal/Now/plainDateTimeISO/timezone-string-datetime': [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/compare/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/PlainDate/from/infinity-throws-rangeerror': [FAIL], 'intl402/Temporal/PlainDate/from/infinity-throws-rangeerror': [FAIL],
'intl402/Temporal/PlainDate/prototype/equals/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