Lines Matching refs:isolate

11 #include "src/execution/isolate.h"
118 V8_WARN_UNUSED_RESULT Handle<String> UnitToString(Isolate* isolate, Unit unit);
130 Isolate* isolate, Handle<String> iso_string);
134 Isolate* isolate, Handle<String> iso_string);
137 Maybe<TimeRecord> ParseTemporalTimeString(Isolate* isolate,
142 Isolate* isolate, Handle<String> string);
146 Isolate* isolate, Handle<String> iso_string);
150 Isolate* isolate, Handle<String> offset_string,
155 Isolate* isolate, Handle<String> iso_string);
157 void BalanceISODate(Isolate* isolate, int32_t* year, int32_t* month,
163 Isolate* isolate, Handle<BigInt> epoch_nanoseconds, int64_t hours,
169 Isolate* isolate, int64_t* days, int64_t* hours, int64_t* minutes,
175 Isolate* isolate, int32_t y1, int32_t mon1, int32_t d1, int32_t h1,
183 Isolate* isolate, int32_t year, int32_t month, int32_t day, int32_t hour,
190 Isolate* isolate, Handle<BigInt> eopch_nanoseconds,
195 Isolate* isolate, Handle<BigInt> eopch_nanoseconds,
201 bool IsValidEpochNanoseconds(Isolate* isolate,
205 bool IsValidDuration(Isolate* isolate, const DurationRecord& dur);
209 Isolate* isolate, Handle<BigInt> nanoseconds,
215 Isolate* isolate, int64_t nanoseconds, Handle<Object> relative_to_obj,
223 MaybeHandle<BigInt> GetEpochFromISOParts(Isolate* isolate, int32_t year,
233 int32_t ISODaysInMonth(Isolate* isolate, int32_t year, int32_t month);
236 int32_t ISODaysInYear(Isolate* isolate, int32_t year);
238 bool IsValidTime(Isolate* isolate, int32_t hour, int32_t minute, int32_t second,
242 bool IsValidISODate(Isolate* isolate, int32_t year, int32_t month, int32_t day);
245 int32_t CompareISODate(Isolate* isolate, int32_t y1, int32_t m1, int32_t d1,
249 void BalanceISOYearMonth(Isolate* isolate, int32_t* year, int32_t* month);
253 BalanceTime(Isolate* isolate, int64_t hour, int64_t minute, int64_t second,
258 DifferenceTime(Isolate* isolate, int32_t h1, int32_t min1, int32_t s1,
264 AddTime(Isolate* isolate, int64_t hour, int64_t minute, int64_t second,
270 int64_t TotalDurationNanoseconds(Isolate* isolate, int64_t days, int64_t hours,
276 Maybe<TimeRecord> ToTemporalTimeRecord(Isolate* isolate,
283 Isolate* isolate, Handle<JSReceiver> calendar, Handle<Object> date,
288 Isolate* isolate, Handle<JSReceiver> calendar, Handle<Object> one,
292 MaybeHandle<FixedArray> CalendarFields(Isolate* isolate,
298 Isolate* isolate, Handle<JSReceiver> time_zone, Handle<Object> instant,
303 Isolate* isolate, Handle<Object> temporal_calendar_like,
307 bool IsBuiltinCalendar(Isolate* isolate, Handle<String> id);
310 int32_t CalendarIndex(Isolate* isolate, Handle<String> id);
313 bool IsValidTimeZoneName(Isolate* isolate, Handle<String> time_zone);
317 Isolate* isolate, Handle<String> identifier);
320 MaybeHandle<Object> ToIntegerThrowOnInfinity(Isolate* isolate,
324 MaybeHandle<Object> ToPositiveInteger(Isolate* isolate,
354 isolate->factory()->NewStringFromStaticChars(TEMPORAL_DEBUG_INFO))
359 isolate->factory()->NewStringFromStaticChars(TEMPORAL_DEBUG_INFO))
362 MaybeHandle<String> DefaultTimeZone(Isolate* isolate) {
366 return isolate->factory()->UTC_string();
370 bool ISODateTimeWithinLimits(Isolate* isolate, int32_t year, int32_t month,
434 isolate, map, \
435 JSFunction::GetDerivedMap(isolate, target, new_target_receiver), T); \
437 Handle<T>::cast(isolate->factory()->NewFastOrSlowJSObjectFromMap(map));
440 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(), T);
445 isolate->context().native_context().temporal_##name##_function()), \
446 isolate)
449 MaybeHandle<BigInt> SystemUTCEpochNanoseconds(Isolate* isolate) {
460 return BigInt::FromNumber(isolate, isolate->factory()->NewNumber(ns));
465 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
473 int32_t index = CalendarIndex(isolate, identifier);
486 Isolate* isolate, Handle<String> identifier) {
488 return CreateTemporalCalendar(isolate, CONSTRUCTOR(calendar),
494 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
504 if (!IsValidISODate(isolate, iso_year, iso_month, iso_day)) {
509 if (!ISODateTimeWithinLimits(isolate, iso_year, iso_month, iso_day, 12, 0, 0,
534 Isolate* isolate, int32_t iso_year, int32_t iso_month, int32_t iso_day,
537 return CreateTemporalDate(isolate, CONSTRUCTOR(plain_date),
544 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
554 if (!IsValidISODate(isolate, iso_year, iso_month, iso_day)) {
559 if (!IsValidTime(isolate, hour, minute, second, millisecond, microsecond,
565 if (!ISODateTimeWithinLimits(isolate, iso_year, iso_month, iso_day, hour,
608 Isolate* isolate, int32_t iso_year, int32_t iso_month, int32_t iso_day,
612 return CreateTemporalDateTime(isolate, CONSTRUCTOR(plain_date_time),
623 Isolate* isolate, int32_t iso_year, int32_t iso_month, int32_t iso_day,
627 isolate, iso_year, iso_month, iso_day, hour, minute, second, millisecond,
636 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
642 if (!IsValidTime(isolate, hour, minute, second, millisecond, microsecond,
654 ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
655 temporal::GetISO8601Calendar(isolate),
679 Isolate* isolate, int32_t hour, int32_t minute, int32_t second,
682 return CreateTemporalTime(isolate, CONSTRUCTOR(plain_time),
689 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
697 if (!IsValidISODate(isolate, reference_iso_year, iso_month, iso_day)) {
721 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
729 if (!IsValidISODate(isolate, iso_year, iso_month, reference_iso_day)) {
758 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
764 DCHECK(IsValidEpochNanoseconds(isolate, epoch_nanoseconds));
784 Isolate* isolate, Handle<BigInt> epoch_nanoseconds,
787 return CreateTemporalZonedDateTime(isolate, CONSTRUCTOR(zoned_date_time),
794 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
799 Factory* factory = isolate->factory();
803 if (!IsValidDuration(isolate,
847 Isolate* isolate, int64_t years, int64_t months, int64_t weeks,
851 return CreateTemporalDuration(isolate, CONSTRUCTOR(duration),
863 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
868 DCHECK(IsValidEpochNanoseconds(isolate, epoch_nanoseconds));
881 Isolate* isolate, Handle<BigInt> epoch_nanoseconds) {
883 return CreateTemporalInstant(isolate, CONSTRUCTOR(instant),
892 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
906 Isolate* isolate, Handle<JSFunction> target,
909 return CreateTemporalTimeZoneFromIndex(isolate, target, new_target, 0);
912 bool IsUTC(Isolate* isolate, Handle<String> time_zone);
916 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
924 if (IsUTC(isolate, identifier)) {
925 return CreateTemporalTimeZoneUTC(isolate, target, new_target);
930 Intl::GetTimeZoneIndex(isolate, identifier, &time_zone_index);
933 return CreateTemporalTimeZoneFromIndex(isolate, target, new_target,
946 ParseTimeZoneOffsetString(isolate, identifier, false);
961 Isolate* isolate, Handle<String> identifier) {
963 return CreateTemporalTimeZone(isolate, CONSTRUCTOR(time_zone),
971 Isolate* isolate, Handle<String> identifier) {
972 return CreateTemporalTimeZoneDefaultTarget(isolate, identifier);
979 MaybeHandle<JSTemporalInstant> SystemInstant(Isolate* isolate) {
983 ASSIGN_RETURN_ON_EXCEPTION(isolate, ns, SystemUTCEpochNanoseconds(isolate),
986 return temporal::CreateTemporalInstant(isolate, ns);
990 MaybeHandle<JSTemporalTimeZone> SystemTimeZone(Isolate* isolate) {
993 ASSIGN_RETURN_ON_EXCEPTION(isolate, default_time_zone,
994 DefaultTimeZone(isolate), JSTemporalTimeZone);
995 return temporal::CreateTemporalTimeZone(isolate, default_time_zone);
999 Isolate* isolate, Handle<BigInt> epoch_nanoseconds) {
1003 Handle<BigInt> million = BigInt::FromInt64(isolate, 1000000);
1006 isolate, remainder_ns,
1007 BigInt::Remainder(isolate, epoch_nanoseconds, million),
1012 isolate, remainder_ns, BigInt::Add(isolate, remainder_ns, million),
1019 isolate, bigint,
1020 BigInt::Subtract(isolate, epoch_nanoseconds, remainder_ns),
1022 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, bigint,
1023 BigInt::Divide(isolate, bigint, million),
1034 isolate->date_cache()->BreakDownTime(epoch_milliseconds, &year, &month, &day,
1076 DateTimeRecordCommon BalanceISODateTime(Isolate* isolate, int32_t year,
1088 isolate, hour, minute, second, millisecond, microsecond, nanosecond);
1092 BalanceISODate(isolate, &year, &month, &day);
1114 Isolate* isolate, Handle<JSReceiver> time_zone,
1120 GetOffsetNanosecondsFor(isolate, time_zone, instant, method_name);
1124 isolate, Handle<BigInt>(instant->nanoseconds(), isolate));
1133 result = BalanceISODateTime(isolate, result.year, result.month, result.day,
1142 isolate, result.year, result.month, result.day, result.hour,
1151 MaybeHandle<FixedArray> GetPossibleInstantsFor(Isolate* isolate,
1159 isolate, function,
1160 Object::GetProperty(isolate, time_zone,
1161 isolate->factory()->getPossibleInstantsFor_string()),
1165 isolate,
1167 isolate->factory()->getPossibleInstantsFor_string()),
1174 isolate, possible_instants,
1175 Execution::Call(isolate, function, time_zone, arraysize(argv), argv),
1184 isolate, possible_instants,
1186 isolate, isolate->temporal_instant_fixed_array_from_iterable(),
1197 Isolate* isolate, Handle<FixedArray> possible_instants,
1212 Handle<Object> ret_obj = FixedArray::get(*possible_instants, 0, isolate);
1222 Handle<Object> ret_obj = FixedArray::get(*possible_instants, 0, isolate);
1230 FixedArray::get(*possible_instants, n - 1, isolate);
1237 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
1245 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
1255 isolate, epoch_nanoseconds,
1257 isolate, date_time->iso_year(), date_time->iso_month(),
1265 Handle<BigInt> one_day_in_ns = BigInt::FromUint64(isolate, 86400000000000ULL);
1268 isolate, day_before_ns,
1269 BigInt::Subtract(isolate, epoch_nanoseconds, one_day_in_ns),
1273 isolate, day_before,
1274 temporal::CreateTemporalInstant(isolate, day_before_ns),
1280 isolate, day_after_ns,
1281 BigInt::Add(isolate, epoch_nanoseconds, one_day_in_ns),
1285 isolate, day_after,
1286 temporal::CreateTemporalInstant(isolate, day_after_ns),
1290 GetOffsetNanosecondsFor(isolate, time_zone, day_before, method_name);
1294 GetOffsetNanosecondsFor(isolate, time_zone, day_after, method_name);
1311 isolate, date_time->iso_year(), date_time->iso_month(),
1315 handle(date_time->calendar(), isolate),
1317 isolate->factory()->undefined_value());
1328 isolate, earlier_date_time,
1330 isolate, earlier.year, earlier.month, earlier.day, earlier.hour,
1333 handle(date_time->calendar(), isolate)),
1339 isolate, possible_instants,
1340 GetPossibleInstantsFor(isolate, time_zone, earlier_date_time),
1345 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
1349 Handle<Object> ret_obj = FixedArray::get(*possible_instants, 0, isolate);
1362 isolate, date_time->iso_year(), date_time->iso_month(),
1366 handle(date_time->calendar(), isolate),
1368 isolate->factory()->undefined_value());
1380 isolate, later_date_time,
1382 isolate, later.year, later.month, later.day, later.hour, later.minute,
1384 handle(date_time->calendar(), isolate)),
1389 isolate, possible_instants,
1390 GetPossibleInstantsFor(isolate, time_zone, later_date_time),
1396 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
1400 Handle<Object> ret_obj = FixedArray::get(*possible_instants, n - 1, isolate);
1407 Isolate* isolate, Handle<JSReceiver> item, const char* method_name) {
1410 Factory* factory = isolate->factory();
1417 return handle(Handle<JSTemporalPlainDate>::cast(item)->calendar(), isolate);
1421 isolate);
1425 isolate);
1428 return handle(Handle<JSTemporalPlainTime>::cast(item)->calendar(), isolate);
1432 isolate);
1436 isolate);
1442 isolate, calendar,
1443 JSReceiver::GetProperty(isolate, item, factory->calendar_string()),
1446 return ToTemporalCalendarWithISODefault(isolate, calendar, method_name);
1455 Isolate* isolate, Handle<JSReceiver> fields, Handle<FixedArray> field_names,
1459 Factory* factory = isolate->factory();
1463 isolate->factory()->NewJSObject(isolate->object_function());
1468 Handle<Object> property_obj = Handle<Object>(field_names->get(i), isolate);
1473 isolate, value, JSReceiver::GetProperty(isolate, fields, property),
1484 String::Equals(isolate, property, factory->day_string())) ||
1487 String::Equals(isolate, property, factory->timeZone_string())) ||
1489 String::Equals(isolate, property, factory->offset_string()))) {
1491 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_TYPE_ERROR(),
1497 if (String::Equals(isolate, property, factory->hour_string()) ||
1498 String::Equals(isolate, property, factory->minute_string()) ||
1499 String::Equals(isolate, property, factory->second_string()) ||
1500 String::Equals(isolate, property, factory->millisecond_string()) ||
1501 String::Equals(isolate, property, factory->microsecond_string()) ||
1502 String::Equals(isolate, property, factory->nanosecond_string())) {
1503 value = Handle<Object>(Smi::zero(), isolate);
1514 if (String::Equals(isolate, property, factory->month_string()) ||
1515 String::Equals(isolate, property, factory->day_string())) {
1516 ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
1517 ToPositiveInteger(isolate, value), JSObject);
1518 } else if (String::Equals(isolate, property, factory->year_string()) ||
1519 String::Equals(isolate, property, factory->hour_string()) ||
1520 String::Equals(isolate, property, factory->minute_string()) ||
1521 String::Equals(isolate, property, factory->second_string()) ||
1522 String::Equals(isolate, property,
1524 String::Equals(isolate, property,
1526 String::Equals(isolate, property,
1528 String::Equals(isolate, property, factory->eraYear_string())) {
1530 isolate, value, ToIntegerThrowOnInfinity(isolate, value), JSObject);
1531 } else if (String::Equals(isolate, property,
1533 String::Equals(isolate, property, factory->offset_string()) ||
1534 String::Equals(isolate, property, factory->era_string())) {
1535 ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
1536 Object::ToString(isolate, value), JSObject);
1541 CHECK(JSReceiver::CreateDataProperty(isolate, result, property, value,
1551 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_TYPE_ERROR(), JSObject);
1560 Isolate* isolate, Handle<JSReceiver> fields, Handle<FixedArray> field_names,
1564 return PrepareTemporalFieldsOrPartial(isolate, fields, field_names, required,
1570 MaybeHandle<T> FromFields(Isolate* isolate, Handle<JSReceiver> calendar,
1575 isolate, function, Object::GetProperty(isolate, calendar, property), T);
1577 THROW_NEW_ERROR(isolate,
1584 isolate, result, Execution::Call(isolate, function, calendar, 2, argv),
1588 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_TYPE_ERROR(), T);
1594 MaybeHandle<JSTemporalPlainDate> DateFromFields(Isolate* isolate,
1599 isolate, calendar, fields, options,
1600 isolate->factory()->dateFromFields_string(), JS_TEMPORAL_PLAIN_DATE_TYPE);
1605 Isolate* isolate, Handle<JSReceiver> calendar, Handle<JSReceiver> fields,
1608 isolate, calendar, fields, options,
1609 isolate->factory()->yearMonthFromFields_string(),
1615 Isolate* isolate, Handle<JSReceiver> calendar, Handle<JSReceiver> fields,
1618 isolate, calendar, fields, options,
1619 isolate->factory()->monthDayFromFields_string(),
1624 Maybe<ShowOverflow> ToTemporalOverflow(Isolate* isolate,
1628 isolate, options, "overflow", method_name, {"constrain", "reject"},
1635 Isolate* isolate, Handle<JSReceiver> time_zone,
1643 isolate, possible_instants,
1644 GetPossibleInstantsFor(isolate, time_zone, date_time), JSTemporalInstant);
1647 return DisambiguatePossibleInstants(isolate, possible_instants, time_zone,
1652 MaybeHandle<JSTemporalInstant> ToTemporalInstant(Isolate* isolate,
1667 handle(JSTemporalZonedDateTime::cast(*item).nanoseconds(), isolate);
1668 return temporal::CreateTemporalInstant(isolate, nanoseconds);
1672 ASSIGN_RETURN_ON_EXCEPTION(isolate, string, Object::ToString(isolate, item),
1677 ASSIGN_RETURN_ON_EXCEPTION(isolate, epoch_nanoseconds,
1678 ParseTemporalInstant(isolate, string),
1682 return temporal::CreateTemporalInstant(isolate, epoch_nanoseconds);
1691 Isolate* isolate, Handle<Object> temporal_calendar_like,
1693 Factory* factory = isolate->factory();
1704 return handle(Handle<JSTemporal##T>::cast(obj)->calendar(), isolate); \
1720 JSReceiver::HasProperty(isolate, obj, factory->calendar_string());
1728 isolate, temporal_calendar_like,
1729 JSReceiver::GetProperty(isolate, obj, factory->calendar_string()),
1736 JSReceiver::HasProperty(isolate, obj, factory->calendar_string());
1747 ASSIGN_RETURN_ON_EXCEPTION(isolate, identifier,
1748 Object::ToString(isolate, temporal_calendar_like),
1751 if (!IsBuiltinCalendar(isolate, identifier)) {
1753 ASSIGN_RETURN_ON_EXCEPTION(isolate, identifier,
1754 ParseTemporalCalendarString(isolate, identifier),
1758 return CreateTemporalCalendar(isolate, identifier);
1766 Isolate* isolate, Handle<Object> temporal_calendar_like,
1773 return temporal::GetISO8601Calendar(isolate);
1776 return temporal::ToTemporalCalendar(isolate, temporal_calendar_like,
1781 MaybeHandle<JSTemporalPlainDate> ToTemporalDate(Isolate* isolate,
1787 Factory* factory = isolate->factory();
1805 isolate, instant,
1807 isolate, Handle<BigInt>(zoned_date_time->nanoseconds(), isolate)),
1814 isolate, plain_date_time,
1816 isolate,
1817 Handle<JSReceiver>(zoned_date_time->time_zone(), isolate),
1818 instant, Handle<JSReceiver>(zoned_date_time->calendar(), isolate),
1825 isolate, plain_date_time->iso_year(), plain_date_time->iso_month(),
1827 Handle<JSReceiver>(plain_date_time->calendar(), isolate));
1836 return CreateTemporalDate(isolate, date_time->iso_year(),
1838 handle(date_time->calendar(), isolate));
1844 isolate, calendar,
1845 GetTemporalCalendarWithISODefault(isolate, item, method_name),
1850 field_names->set(0, ReadOnlyRoots(isolate).day_string());
1851 field_names->set(1, ReadOnlyRoots(isolate).month_string());
1852 field_names->set(2, ReadOnlyRoots(isolate).monthCode_string());
1853 field_names->set(3, ReadOnlyRoots(isolate).year_string());
1854 ASSIGN_RETURN_ON_EXCEPTION(isolate, field_names,
1855 CalendarFields(isolate, calendar, field_names),
1860 ASSIGN_RETURN_ON_EXCEPTION(isolate, fields,
1861 PrepareTemporalFields(isolate, item, field_names,
1865 return DateFromFields(isolate, calendar, fields, options);
1869 ToTemporalOverflow(isolate, options, method_name);
1874 ASSIGN_RETURN_ON_EXCEPTION(isolate, string,
1875 Object::ToString(isolate, item_obj),
1878 Maybe<DateRecord> maybe_result = ParseTemporalDateString(isolate, string);
1884 DCHECK(IsValidISODate(isolate, result.year, result.month, result.day));
1894 isolate, calendar,
1895 ToTemporalCalendarWithISODefault(isolate, calendar_string, method_name),
1899 return CreateTemporalDate(isolate, result.year, result.month, result.day,
1908 Maybe<bool> RegulateTime(Isolate* isolate, TimeRecord* time,
1931 if (!IsValidTime(isolate, time->hour, time->minute, time->second,
1935 isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(), Nothing<bool>());
1945 MaybeHandle<JSTemporalPlainTime> ToTemporalTime(Isolate* isolate,
1949 Factory* factory = isolate->factory();
1968 isolate, instant,
1970 isolate, Handle<BigInt>(zoned_date_time->nanoseconds(), isolate)),
1977 isolate, plain_date_time,
1979 isolate,
1980 Handle<JSReceiver>(zoned_date_time->time_zone(), isolate),
1981 instant, Handle<JSReceiver>(zoned_date_time->calendar(), isolate),
1990 isolate, plain_date_time->iso_hour(), plain_date_time->iso_minute(),
2003 isolate, date_time->iso_hour(), date_time->iso_minute(),
2010 isolate, calendar,
2011 GetTemporalCalendarWithISODefault(isolate, item, method_name),
2015 ASSIGN_RETURN_ON_EXCEPTION(isolate, identifier,
2016 Object::ToString(isolate, calendar),
2018 if (!String::Equals(isolate, factory->iso8601_string(), identifier)) {
2020 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2025 ToTemporalTimeRecord(isolate, item, method_name);
2031 Maybe<bool> maybe_regulate_time = RegulateTime(isolate, &result, overflow);
2038 ASSIGN_RETURN_ON_EXCEPTION(isolate, string,
2039 Object::ToString(isolate, item_obj),
2042 Maybe<TimeRecord> maybe_result = ParseTemporalTimeString(isolate, string);
2048 DCHECK(IsValidTime(isolate, result.hour, result.minute, result.second,
2053 !String::Equals(isolate, result.calendar,
2054 isolate->factory()->iso8601_string())) {
2056 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2063 return CreateTemporalTime(isolate, result.hour, result.minute, result.second,
2070 Isolate* isolate, Handle<Object> temporal_time_zone_like,
2074 Factory* factory = isolate->factory();
2083 return handle(zoned_date_time->time_zone(), isolate);
2088 JSReceiver::HasProperty(isolate, obj, factory->timeZone_string());
2097 isolate, temporal_time_zone_like,
2098 JSReceiver::GetProperty(isolate, obj, factory->timeZone_string()),
2105 JSReceiver::HasProperty(isolate, obj, factory->timeZone_string());
2115 ASSIGN_RETURN_ON_EXCEPTION(isolate, identifier,
2116 Object::ToString(isolate, temporal_time_zone_like),
2121 isolate, result, ParseTemporalTimeZone(isolate, identifier), JSReceiver);
2124 return temporal::CreateTemporalTimeZone(isolate, result);
2132 Isolate* isolate, Handle<Object> temporal_time_zone_like,
2140 ASSIGN_RETURN_ON_EXCEPTION(isolate, time_zone, SystemTimeZone(isolate),
2146 isolate, time_zone,
2147 temporal::ToTemporalTimeZone(isolate, temporal_time_zone_like,
2154 isolate, calendar,
2155 temporal::ToTemporalCalendar(isolate, calendar_like, method_name),
2159 ASSIGN_RETURN_ON_EXCEPTION(isolate, instant, SystemInstant(isolate),
2164 isolate, time_zone, instant, calendar, method_name);
2168 Isolate* isolate, Handle<Object> temporal_time_zone_like,
2176 ASSIGN_RETURN_ON_EXCEPTION(isolate, time_zone, SystemTimeZone(isolate),
2182 isolate, time_zone,
2183 temporal::ToTemporalTimeZone(isolate, temporal_time_zone_like,
2190 isolate, calendar,
2191 temporal::ToTemporalCalendar(isolate, calendar_like, method_name),
2195 ASSIGN_RETURN_ON_EXCEPTION(isolate, ns, SystemUTCEpochNanoseconds(isolate),
2198 return CreateTemporalZonedDateTime(isolate, ns, time_zone, calendar);
2207 MaybeHandle<String> FormatTimeZoneOffsetString(Isolate* isolate,
2209 IncrementalStringBuilder builder(isolate);
2266 Isolate* isolate, Handle<JSReceiver> time_zone,
2271 GetOffsetNanosecondsFor(isolate, time_zone, instant, method_name);
2276 return FormatTimeZoneOffsetString(isolate, offset_nanoseconds);
2280 Maybe<DateTimeRecord> ParseISODateTime(Isolate* isolate,
2342 if (!IsValidISODate(isolate, result.year, result.month, result.day)) {
2343 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2348 if (!IsValidTime(isolate, result.hour, result.minute, result.second,
2350 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2358 result.calendar = isolate->factory()->empty_string();
2360 result.calendar = isolate->factory()->NewSubString(
2368 Maybe<DateRecord> ParseTemporalDateString(Isolate* isolate,
2375 TemporalParser::ParseTemporalDateString(isolate, iso_string);
2378 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2387 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2392 ParseISODateTime(isolate, iso_string, parsed);
2404 Maybe<TimeRecord> ParseTemporalTimeString(Isolate* isolate,
2412 TemporalParser::ParseTemporalTimeString(isolate, iso_string);
2416 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2423 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2429 ParseISODateTime(isolate, iso_string, parsed);
2443 Maybe<InstantRecord> ParseTemporalInstantString(Isolate* isolate,
2451 TemporalParser::ParseTemporalInstantString(isolate, iso_string);
2453 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2459 ParseISODateTime(isolate, iso_string, maybe_parsed.FromJust());
2466 ParseTemporalTimeZoneString(isolate, iso_string);
2474 offset_string = isolate->factory()->NewStringFromStaticChars("+00:00");
2502 MaybeHandle<BigInt> ParseTemporalInstant(Isolate* isolate,
2506 Factory* factory = isolate->factory();
2510 ParseTemporalInstantString(isolate, iso_string);
2523 isolate, utc,
2524 GetEpochFromISOParts(isolate, result.year, result.month, result.day,
2536 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(), BigInt);
2540 ParseTimeZoneOffsetString(isolate, result.offset_string);
2545 return BigInt::Subtract(isolate, utc,
2546 BigInt::FromInt64(isolate, offset_nanoseconds));
2550 Maybe<TimeZoneRecord> ParseTemporalTimeZoneString(Isolate* isolate,
2558 TemporalParser::ParseTemporalTimeZoneString(isolate, iso_string);
2561 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2575 Handle<String> name = isolate->factory()->NewSubString(
2578 TimeZoneRecord ret({true, isolate->factory()->empty_string(), name});
2581 TimeZoneRecord ret({true, isolate->factory()->empty_string(),
2582 isolate->factory()->empty_string()});
2626 isolate, offset_string,
2627 FormatTimeZoneOffsetString(isolate, offset_nanoseconds),
2634 name = isolate->factory()->NewSubString(
2639 if (!IsValidTimeZoneName(isolate, name)) {
2640 THROW_NEW_ERROR_RETURN_VALUE(isolate,
2645 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, name,
2646 CanonicalizeTimeZoneName(isolate, name),
2653 : isolate->factory()->empty_string(),
2662 : isolate->factory()->empty_string(),
2663 isolate->factory()->empty_string()});
2668 MaybeHandle<String> ParseTemporalTimeZone(Isolate* isolate,
2674 ParseTemporalTimeZoneString(isolate, string);
2685 return isolate->factory()->UTC_string();
2692 Maybe<int64_t> ParseTimeZoneOffsetString(Isolate* isolate,
2701 TemporalParser::ParseTimeZoneNumericUTCOffset(isolate, iso_string);
2705 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2715 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
2750 Maybe<bool> IsValidTimeZoneNumericUTCOffsetString(Isolate* isolate,
2755 TemporalParser::ParseTimeZoneNumericUTCOffset(isolate, iso_string);
2760 MaybeHandle<String> ParseTemporalCalendarString(Isolate* isolate,
2768 TemporalParser::ParseTemporalCalendarString(isolate, iso_string);
2771 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(), String);
2779 return isolate->factory()->iso8601_string();
2781 Handle<String> id = isolate->factory()->NewSubString(
2785 if (!IsBuiltinCalendar(isolate, id)) {
2788 isolate, NewRangeError(MessageTemplate::kInvalidCalendar, id), String);
2795 MaybeHandle<FixedArray> CalendarFields(Isolate* isolate,
2801 isolate, fields,
2802 Object::GetMethod(calendar, isolate->factory()->fields_string()),
2806 isolate->factory()->NewJSArrayWithElements(field_names);
2812 isolate, fields_array,
2813 Execution::Call(isolate, fields, calendar, 1, argv), FixedArray);
2818 isolate, fields_array,
2819 Execution::CallBuiltin(isolate,
2820 isolate->string_fixed_array_from_iterable(),
2827 MaybeHandle<JSTemporalPlainDate> CalendarDateAdd(Isolate* isolate,
2832 return CalendarDateAdd(isolate, calendar, date, duration, options,
2833 isolate->factory()->undefined_value());
2837 Isolate* isolate, Handle<JSReceiver> calendar, Handle<Object> date,
2844 isolate, date_add,
2845 Object::GetMethod(calendar, isolate->factory()->dateAdd_string()),
2852 isolate, added_date,
2853 Execution::Call(isolate, date_add, calendar, arraysize(argv), argv),
2857 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_TYPE_ERROR(),
2864 MaybeHandle<JSTemporalDuration> CalendarDateUntil(Isolate* isolate,
2869 return CalendarDateUntil(isolate, calendar, one, two, options,
2870 isolate->factory()->undefined_value());
2874 Isolate* isolate, Handle<JSReceiver> calendar, Handle<Object> one,
2881 isolate, date_until,
2882 Object::GetMethod(calendar, isolate->factory()->dateUntil_string()),
2889 isolate, duration,
2890 Execution::Call(isolate, date_until, calendar, arraysize(argv), argv),
2895 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_TYPE_ERROR(),
2904 Isolate* isolate, Handle<JSReceiver> fields,
2906 Factory* factory = isolate->factory();
2909 isolate->factory()->NewJSObject(isolate->object_function());
2914 isolate, original_keys,
2922 Handle<Object> next_key = handle(original_keys->get(i), isolate);
2925 if (!(String::Equals(isolate, factory->month_string(), next_key_string) ||
2926 String::Equals(isolate, factory->monthCode_string(),
2931 isolate, prop_value,
2932 JSReceiver::GetPropertyOrElement(isolate, fields, next_key_string),
2938 CHECK(JSReceiver::CreateDataProperty(isolate, merged, next_key_string,
2947 isolate, new_keys,
2955 Handle<Object> next_key = handle(new_keys->get(i), isolate);
2960 ASSIGN_RETURN_ON_EXCEPTION(isolate, prop_value,
2962 isolate, additional_fields, next_key_string),
2968 isolate, merged, next_key_string, prop_value, Just(kThrowOnError));
2972 String::Equals(isolate, factory->month_string(), next_key_string) ||
2973 String::Equals(isolate, factory->monthCode_string(), next_key_string);
2979 ASSIGN_RETURN_ON_EXCEPTION(isolate, month,
2981 isolate, fields, factory->month_string()),
2986 CHECK(JSReceiver::CreateDataProperty(isolate, merged,
2994 isolate, month_code,
2995 JSReceiver::GetPropertyOrElement(isolate, fields,
3001 CHECK(JSReceiver::CreateDataProperty(isolate, merged,
3012 Maybe<int64_t> GetOffsetNanosecondsFor(Isolate* isolate,
3021 isolate, get_offset_nanoseconds_for,
3023 isolate->factory()->getOffsetNanosecondsFor_string()),
3027 isolate,
3029 isolate->factory()->getOffsetNanosecondsFor_string()),
3037 isolate, offset_nanoseconds_obj,
3038 Execution::Call(isolate, get_offset_nanoseconds_for, time_zone_obj, 1,
3044 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_TYPE_ERROR(),
3052 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
3060 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
3068 MaybeHandle<Object> ToPositiveInteger(Isolate* isolate,
3074 isolate, argument, ToIntegerThrowOnInfinity(isolate, argument), Object);
3078 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(), Object);
3086 MaybeHandle<Object> InvokeCalendarMethod(Isolate* isolate,
3096 isolate, function, Object::GetProperty(isolate, calendar, name), Object);
3098 THROW_NEW_ERROR(isolate,
3104 isolate, result,
3105 Execution::Call(isolate, function, calendar, arraysize(argv), argv),
3111 MaybeHandle<Object> Calendar##Name(Isolate* isolate, \
3118 isolate, result, \
3119 InvokeCalendarMethod(isolate, calendar, \
3120 isolate->factory()->name##_string(), date_like), \
3124 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(), Object); \
3127 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, Action(isolate, result), \
3129 return Handle<Smi>(Smi::FromInt(result->Number()), isolate); \
3139 MaybeHandle<Object> CalendarMonthCode(Isolate* isolate,
3146 isolate, result,
3147 InvokeCalendarMethod(isolate, calendar,
3148 isolate->factory()->monthCode_string(), date_like),
3152 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(), Object);
3155 return Object::ToString(isolate, result);
3160 MaybeHandle<Object> CalendarEraYear(Isolate* isolate,
3167 isolate, result,
3168 InvokeCalendarMethod(isolate, calendar,
3169 isolate->factory()->eraYear_string(), date_like),
3174 isolate, result, ToIntegerThrowOnInfinity(isolate, result), Object);
3181 MaybeHandle<Object> CalendarEra(Isolate* isolate, Handle<JSReceiver> calendar,
3187 isolate, result,
3188 InvokeCalendarMethod(isolate, calendar, isolate->factory()->era_string(),
3193 ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
3194 Object::ToString(isolate, result), Object);
3203 MaybeHandle<JSTemporalCalendar> GetISO8601Calendar(Isolate* isolate) {
3204 return CreateTemporalCalendar(isolate, isolate->factory()->iso8601_string());
3211 bool IsUTC(Isolate* isolate, Handle<String> time_zone) {
3220 time_zone = String::Flatten(isolate, time_zone);
3270 bool IsBuiltinCalendar(Isolate* isolate, const std::string& id) {
3274 bool IsBuiltinCalendar(Isolate* isolate, Handle<String> id) {
3275 return IsBuiltinCalendar(isolate, id->ToCString().get());
3278 Handle<String> CalendarIdentifier(Isolate* isolate, int32_t index) {
3279 return isolate->factory()->NewStringFromAsciiChecked(
3283 int32_t CalendarIndex(Isolate* isolate, Handle<String> id) {
3287 bool IsValidTimeZoneName(Isolate* isolate, Handle<String> time_zone) {
3288 return Intl::IsValidTimeZoneName(isolate, time_zone);
3291 MaybeHandle<String> CanonicalizeTimeZoneName(Isolate* isolate,
3293 return Intl::CanonicalizeTimeZoneName(isolate, identifier);
3297 Handle<String> CalendarIdentifier(Isolate* isolate, int32_t index) {
3299 return isolate->factory()->iso8601_string();
3303 bool IsBuiltinCalendar(Isolate* isolate, Handle<String> id) {
3306 return isolate->factory()->iso8601_string()->Equals(*id);
3309 int32_t CalendarIndex(Isolate* isolate, Handle<String> id) { return 0; }
3311 bool IsValidTimeZoneName(Isolate* isolate, Handle<String> time_zone) {
3312 return IsUTC(isolate, time_zone);
3315 MaybeHandle<String> CanonicalizeTimeZoneName(Isolate* isolate,
3317 return isolate->factory()->UTC_string();
3322 Maybe<TimeRecord> ToTemporalTimeRecord(Isolate* isolate,
3328 Factory* factory = isolate->factory();
3349 isolate, value,
3350 Object::GetPropertyOrElement(isolate, temporal_time_like, row.first),
3358 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, value,
3359 ToIntegerThrowOnInfinity(isolate, value),
3369 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_TYPE_ERROR(),
3377 MaybeHandle<JSObject> MergeLargestUnitOption(Isolate* isolate,
3383 isolate->factory()->NewJSObject(isolate->object_function());
3389 isolate, merged, options, PropertiesEnumerationMode::kEnumerationOrder,
3395 isolate, merged, isolate->factory()->largestUnit_string(),
3396 UnitToString(isolate, largest_unit), Just(kThrowOnError))
3403 MaybeHandle<Object> ToIntegerThrowOnInfinity(Isolate* isolate,
3408 ASSIGN_RETURN_ON_EXCEPTION(isolate, argument,
3409 Object::ToInteger(isolate, argument), Object);
3413 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(), Object);
3419 Unit LargerOfTwoTemporalUnits(Isolate* isolate, Unit u1, Unit u2) {
3444 Handle<String> UnitToString(Isolate* isolate, Unit unit) {
3447 return ReadOnlyRoots(isolate).year_string_handle();
3449 return ReadOnlyRoots(isolate).month_string_handle();
3451 return ReadOnlyRoots(isolate).week_string_handle();
3453 return ReadOnlyRoots(isolate).day_string_handle();
3455 return ReadOnlyRoots(isolate).hour_string_handle();
3457 return ReadOnlyRoots(isolate).minute_string_handle();
3459 return ReadOnlyRoots(isolate).second_string_handle();
3461 return ReadOnlyRoots(isolate).millisecond_string_handle();
3463 return ReadOnlyRoots(isolate).microsecond_string_handle();
3465 return ReadOnlyRoots(isolate).nanosecond_string_handle();
3472 void BalanceISODate(Isolate* isolate, int32_t* year, int32_t* month,
3480 BalanceISOYearMonth(isolate, year, month);
3491 while (*day < -(iso_days_in_year = ISODaysInYear(isolate, test_year))) {
3505 while (*day > (iso_days_in_year = ISODaysInYear(isolate, test_year))) {
3522 BalanceISOYearMonth(isolate, year, month);
3524 *day += ISODaysInMonth(isolate, *year, *month);
3531 while (*day > (iso_days_in_month = ISODaysInMonth(isolate, *year, *month))) {
3538 BalanceISOYearMonth(isolate, year, month);
3547 Isolate* isolate, int32_t year, int32_t month, int32_t day, int32_t hour,
3559 AddTime(isolate, hour, minute, second, millisecond, microsecond,
3566 isolate, date_part,
3567 CreateTemporalDate(isolate, year, month, day, calendar),
3573 isolate, date_duration,
3574 CreateTemporalDuration(isolate, dur.years, dur.months, dur.weeks,
3581 isolate, added_date,
3582 CalendarDateAdd(isolate, calendar, date_part, date_duration, options),
3596 Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours,
3604 return BalanceDuration(isolate, days, hours, minutes, seconds, milliseconds,
3606 isolate->factory()->undefined_value(), method_name);
3609 Maybe<bool> BalanceDuration(Isolate* isolate, int64_t* days, int64_t* hours,
3627 isolate, end_ns,
3628 AddZonedDateTime(isolate,
3629 Handle<BigInt>(relative_to->nanoseconds(), isolate),
3630 Handle<JSReceiver>(relative_to->time_zone(), isolate),
3631 Handle<JSReceiver>(relative_to->calendar(), isolate),
3638 isolate, end_ns,
3639 BigInt::Subtract(isolate, end_ns,
3640 Handle<BigInt>(relative_to->nanoseconds(), isolate)),
3648 TotalDurationNanoseconds(isolate, *days, *hours, *minutes, *seconds,
3657 NanosecondsToDays(isolate, *nanoseconds, relative_to_obj, days,
3776 MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate,
3785 Handle<JSReceiver> options = isolate->factory()->NewJSObjectWithNullProto();
3786 return AddZonedDateTime(isolate, epoch_nanoseconds, time_zone, calendar,
3791 MaybeHandle<BigInt> AddZonedDateTime(Isolate* isolate,
3805 return AddInstant(isolate, epoch_nanoseconds, duration.hours,
3812 isolate, instant,
3813 temporal::CreateTemporalInstant(isolate, epoch_nanoseconds), BigInt);
3819 isolate, temporal_date_time,
3820 temporal::BuiltinTimeZoneGetPlainDateTimeFor(isolate, time_zone, instant,
3827 isolate, date_part,
3828 CreateTemporalDate(isolate, temporal_date_time->iso_year(),
3836 isolate, date_duration,
3837 CreateTemporalDuration(isolate, duration.years, duration.months,
3844 isolate, added_date,
3845 CalendarDateAdd(isolate, calendar, date_part, date_duration, options),
3855 isolate, intermediate_date_time,
3857 isolate, added_date->iso_year(), added_date->iso_month(),
3868 isolate, intermediate_instant,
3869 BuiltinTimeZoneGetInstantFor(isolate, time_zone, intermediate_date_time,
3875 isolate, Handle<BigInt>(intermediate_instant->nanoseconds(), isolate),
3881 Maybe<bool> NanosecondsToDays(Isolate* isolate, int64_t nanoseconds,
3886 return NanosecondsToDays(isolate, BigInt::FromInt64(isolate, nanoseconds),
3891 Maybe<bool> NanosecondsToDays(Isolate* isolate, Handle<BigInt> nanoseconds,
3902 BigInt::CompareToBigInt(nanoseconds, BigInt::FromInt64(isolate, 0));
3905 Handle<BigInt> day_length_ns = BigInt::FromInt64(isolate, 86400000000000LLU);
3924 isolate, days_bigint,
3925 BigInt::Divide(isolate, nanoseconds, day_length_ns), Nothing<bool>());
3928 nanoseconds = BigInt::UnaryMinus(isolate, nanoseconds);
3932 isolate, nanoseconds,
3933 BigInt::Remainder(isolate, nanoseconds, day_length_ns),
3943 Handle<BigInt> start_ns = Handle<BigInt>(relative_to->nanoseconds(), isolate);
3947 isolate, start_instant,
3949 isolate, Handle<BigInt>(relative_to->nanoseconds(), isolate)),
3956 Handle<JSReceiver>(relative_to->time_zone(), isolate);
3958 Handle<JSReceiver>(relative_to->calendar(), isolate);
3961 isolate, start_date_time,
3963 isolate, time_zone, start_instant, calendar, method_name),
3968 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, end_ns,
3969 BigInt::Add(isolate, start_ns, nanoseconds),
3975 isolate, end_instant, temporal::CreateTemporalInstant(isolate, end_ns),
3982 isolate, end_date_time,
3984 isolate, time_zone, end_instant, calendar, method_name),
3999 isolate, start_date_time->iso_year(), start_date_time->iso_month(),
4020 isolate, intermediate_ns,
4021 AddZonedDateTime(isolate, start_ns, time_zone, calendar,
4036 isolate, intermediate_ns,
4037 AddZonedDateTime(isolate, start_ns, time_zone, calendar,
4045 isolate, nanoseconds, BigInt::Subtract(isolate, end_ns, intermediate_ns),
4058 isolate, one_day_farther_ns,
4059 AddZonedDateTime(isolate, intermediate_ns, time_zone, calendar,
4066 isolate, day_length_ns,
4067 BigInt::Subtract(isolate, one_day_farther_ns, intermediate_ns),
4075 isolate, nanoseconds,
4076 BigInt::Subtract(isolate, nanoseconds, day_length_ns),
4100 Isolate* isolate, int32_t y1, int32_t mon1, int32_t d1, int32_t h1,
4107 Factory* factory = isolate->factory();
4122 isolate, h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, ns2);
4135 int32_t time_sign = DurationSign(isolate, time_difference);
4137 int32_t date_sign = CompareISODate(isolate, y2, mon2, d2, y1, mon1, d1);
4143 BalanceISODate(isolate, &balanced_year, &balanced_month, &balanced_day);
4150 BalanceISODate(isolate, &balanced_year, &balanced_month, &balanced_day);
4165 isolate, &(result.days), &(result.hours), &(result.minutes),
4175 isolate, date1,
4176 CreateTemporalDate(isolate, balanced_year, balanced_month, balanced_day,
4182 isolate, date2, CreateTemporalDate(isolate, y2, mon2, d2, calendar),
4186 LargerOfTwoTemporalUnits(isolate, Unit::kDay, largest_unit);
4191 isolate, until_options,
4192 MergeLargestUnitOption(isolate, options, date_largest_unit),
4198 isolate, date_difference,
4199 CalendarDateUntil(isolate, calendar, date1, date2, until_options),
4209 isolate, &(result.days), &(result.hours), &(result.minutes),
4228 MaybeHandle<BigInt> AddInstant(Isolate* isolate,
4242 isolate, result,
4243 BigInt::Add(isolate, epoch_nanoseconds,
4244 BigInt::FromInt64(isolate, nanoseconds)),
4248 isolate, temp,
4249 BigInt::Multiply(isolate, BigInt::FromInt64(isolate, microseconds),
4250 BigInt::FromInt64(isolate, 1000)),
4252 ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
4253 BigInt::Add(isolate, result, temp), BigInt);
4256 isolate, temp,
4257 BigInt::Multiply(isolate, BigInt::FromInt64(isolate, milliseconds),
4258 BigInt::FromInt64(isolate, 1000000)),
4260 ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
4261 BigInt::Add(isolate, result, temp), BigInt);
4264 isolate, temp,
4265 BigInt::Multiply(isolate, BigInt::FromInt64(isolate, seconds),
4266 BigInt::FromInt64(isolate, 1000000000)),
4268 ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
4269 BigInt::Add(isolate, result, temp), BigInt);
4272 isolate, temp,
4273 BigInt::Multiply(isolate, BigInt::FromInt64(isolate, minutes),
4274 BigInt::FromInt64(isolate, 1000000000)),
4277 isolate, temp,
4278 BigInt::Multiply(isolate, temp, BigInt::FromInt64(isolate, 60)), BigInt);
4279 ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
4280 BigInt::Add(isolate, result, temp), BigInt);
4283 isolate, temp,
4284 BigInt::Multiply(isolate, BigInt::FromInt64(isolate, hours),
4285 BigInt::FromInt64(isolate, 1000000000)),
4288 isolate, temp,
4289 BigInt::Multiply(isolate, temp, BigInt::FromInt64(isolate, 3600)),
4291 ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
4292 BigInt::Add(isolate, result, temp), BigInt);
4296 if (!IsValidEpochNanoseconds(isolate, result)) {
4297 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(), BigInt);
4304 bool IsValidEpochNanoseconds(Isolate* isolate,
4316 MaybeHandle<BigInt> GetEpochFromISOParts(Isolate* isolate, int32_t year,
4326 DCHECK(IsValidISODate(isolate, year, month, day));
4329 DCHECK(IsValidTime(isolate, hour, minute, second, millisecond, microsecond,
4341 isolate, result,
4342 BigInt::FromNumber(isolate, isolate->factory()->NewNumber(ms)), BigInt);
4345 isolate, result,
4346 BigInt::Multiply(isolate, result, BigInt::FromInt64(isolate, 1000000)),
4351 isolate, temp,
4352 BigInt::Multiply(isolate, BigInt::FromInt64(isolate, microsecond),
4353 BigInt::FromInt64(isolate, 1000)),
4356 ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
4357 BigInt::Add(isolate, result, temp), BigInt);
4358 return BigInt::Add(isolate, result, BigInt::FromInt64(isolate, nanosecond));
4393 bool IsValidDuration(Isolate* isolate, const DurationRecord& dur) {
4398 int32_t sign = DurationSign(isolate, dur);
4415 bool IsISOLeapYear(Isolate* isolate, int32_t year) {
4423 return isolate->date_cache()->IsLeap(year);
4427 int32_t ISODaysInMonth(Isolate* isolate, int32_t year, int32_t month) {
4440 return IsISOLeapYear(isolate, year) ? 29 : 28;
4445 int32_t ISODaysInYear(Isolate* isolate, int32_t year) {
4452 return IsISOLeapYear(isolate, year) ? 366 : 365;
4455 bool IsValidTime(Isolate* isolate, int32_t hour, int32_t minute, int32_t second,
4482 bool IsValidISODate(Isolate* isolate, int32_t year, int32_t month,
4493 if (day < 1 || day > ISODaysInMonth(isolate, year, month)) return false;
4499 int32_t CompareISODate(Isolate* isolate, int32_t y1, int32_t m1, int32_t d1,
4521 void BalanceISOYearMonth(Isolate* isolate, int32_t* year, int32_t* month) {
4533 DateTimeRecordCommon BalanceTime(Isolate* isolate, int64_t hour, int64_t minute,
4579 DurationRecord DifferenceTime(Isolate* isolate, int32_t h1, int32_t min1,
4602 double sign = DurationSign(isolate, dur);
4608 isolate, dur.hours * sign, dur.minutes * sign, dur.seconds * sign,
4629 DateTimeRecordCommon AddTime(Isolate* isolate, int64_t hour, int64_t minute,
4641 return BalanceTime(isolate, hour + hours,
4657 int64_t TotalDurationNanoseconds(Isolate* isolate, int64_t days, int64_t hours,
4694 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
4703 THROW_NEW_ERROR(isolate,
4705 isolate->factory()->NewStringFromAsciiChecked(
4711 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_years,
4712 ToIntegerThrowOnInfinity(isolate, years),
4718 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_months,
4719 ToIntegerThrowOnInfinity(isolate, months),
4725 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_weeks,
4726 ToIntegerThrowOnInfinity(isolate, weeks),
4732 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_days,
4733 ToIntegerThrowOnInfinity(isolate, days),
4739 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_hours,
4740 ToIntegerThrowOnInfinity(isolate, hours),
4746 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_minutes,
4747 ToIntegerThrowOnInfinity(isolate, minutes),
4753 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_seconds,
4754 ToIntegerThrowOnInfinity(isolate, seconds),
4760 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_milliseconds,
4761 ToIntegerThrowOnInfinity(isolate, milliseconds),
4767 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_microseconds,
4768 ToIntegerThrowOnInfinity(isolate, microseconds),
4774 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_nanoseconds,
4775 ToIntegerThrowOnInfinity(isolate, nanoseconds),
4781 return CreateTemporalDuration(isolate, target, new_target, y, mo, w, d, h, m,
4786 MaybeHandle<Smi> JSTemporalDuration::Sign(Isolate* isolate,
4797 isolate,
4805 isolate);
4810 Isolate* isolate, Handle<JSTemporalDuration> duration) {
4821 isolate,
4829 return sign == 0 ? isolate->factory()->true_value()
4830 : isolate->factory()->false_value();
4836 Isolate* isolate, Handle<JSTemporalDuration> duration) {
4847 isolate, -NumberToInt64(duration->years()),
4860 Isolate* isolate, Handle<JSTemporalDuration> duration) {
4866 return CreateNegatedTemporalDuration(isolate, duration);
4871 Isolate* isolate, Handle<JSTemporalDuration> duration) {
4881 isolate, std::abs(NumberToInt64(duration->years())),
4895 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
4898 if (new_target->IsUndefined(isolate)) {
4900 THROW_NEW_ERROR(isolate,
4902 isolate->factory()->NewStringFromStaticChars(
4908 ASSIGN_RETURN_ON_EXCEPTION(isolate, identifier,
4909 Object::ToString(isolate, identifier_obj),
4912 if (!IsBuiltinCalendar(isolate, identifier)) {
4915 isolate, NewRangeError(MessageTemplate::kInvalidCalendar, identifier),
4918 return CreateTemporalCalendar(isolate, target, new_target, identifier);
4924 int32_t ToISODayOfYear(Isolate* isolate, int32_t year, int32_t month,
4935 return day + isolate->date_cache()->DaysFromYearMonth(year, month - 1) -
4936 isolate->date_cache()->DaysFromYearMonth(year, 0);
4947 int32_t ToISODayOfWeek(Isolate* isolate, int32_t year, int32_t month,
4962 int32_t weekday = isolate->date_cache()->Weekday(
4963 isolate->date_cache()->DaysFromYearMonth(year, month - 1) + day - 1);
4970 Maybe<bool> RegulateISODate(Isolate* isolate, ShowOverflow overflow,
4981 if (!IsValidISODate(isolate, year, *month, *day)) {
4983 isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(), Nothing<bool>());
4994 *day = std::max(std::min(*day, ISODaysInMonth(isolate, year, *month)), 1);
5002 Maybe<int32_t> ResolveISOMonth(Isolate* isolate, Handle<JSReceiver> fields) {
5003 Factory* factory = isolate->factory();
5007 isolate, month_obj,
5008 Object::GetPropertyOrElement(isolate, fields, factory->month_string()),
5013 isolate, month_code_obj,
5014 Object::GetPropertyOrElement(isolate, fields,
5018 if (month_code_obj->IsUndefined(isolate)) {
5020 if (month_obj->IsUndefined(isolate)) {
5022 isolate, NEW_TEMPORAL_INVALD_ARG_TYPE_ERROR(), Nothing<int32_t>());
5034 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, month_code,
5035 Object::ToString(isolate, month_code_obj),
5041 isolate,
5055 isolate,
5072 isolate,
5083 Maybe<bool> ISODateFromFields(Isolate* isolate, Handle<JSReceiver> fields,
5087 Factory* factory = isolate->factory();
5092 ToTemporalOverflow(isolate, options, method_name);
5097 field_names->set(0, ReadOnlyRoots(isolate).day_string());
5098 field_names->set(1, ReadOnlyRoots(isolate).month_string());
5099 field_names->set(2, ReadOnlyRoots(isolate).monthCode_string());
5100 field_names->set(3, ReadOnlyRoots(isolate).year_string());
5102 isolate, fields,
5103 PrepareTemporalFields(isolate, fields, field_names,
5110 isolate, year_obj,
5111 Object::GetPropertyOrElement(isolate, fields, factory->year_string()),
5114 if (year_obj->IsUndefined(isolate)) {
5115 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_TYPE_ERROR(),
5125 Maybe<int32_t> maybe_month = ResolveISOMonth(isolate, fields);
5132 isolate, day_obj,
5133 Object::GetPropertyOrElement(isolate, fields, factory->day_string()),
5136 if (day_obj->IsUndefined(isolate)) {
5137 THROW_NEW_ERROR_RETURN_VALUE(isolate, NEW_TEMPORAL_INVALD_ARG_TYPE_ERROR(),
5146 return RegulateISODate(isolate, maybe_overflow.FromJust(), *year, month, day);
5153 Isolate* isolate, Handle<JSTemporalCalendar> calendar,
5165 isolate, temporal_date_like,
5166 ToTemporalDate(isolate, temporal_date_like,
5167 isolate->factory()->NewJSObjectWithNullProto(),
5184 int32_t days_in_year = ISODaysInYear(isolate, year);
5186 return handle(Smi::FromInt(days_in_year), isolate);
5191 Isolate* isolate, Handle<JSTemporalCalendar> calendar,
5203 isolate, temporal_date_like,
5204 ToTemporalDate(isolate, temporal_date_like,
5205 isolate->factory()->NewJSObjectWithNullProto(),
5229 return handle(Smi::FromInt(ISODaysInMonth(isolate, year, month)), isolate);
5233 MaybeHandle<Smi> JSTemporalCalendar::Year(Isolate* isolate,
5247 isolate, temporal_date_like,
5248 ToTemporalDate(isolate, temporal_date_like,
5249 isolate->factory()->NewJSObjectWithNullProto(),
5268 return handle(Smi::FromInt(year), isolate);
5273 Isolate* isolate, Handle<JSTemporalCalendar> calendar,
5282 isolate, temporal_date,
5283 ToTemporalDate(isolate, temporal_date_like,
5284 isolate->factory()->NewJSObjectWithNullProto(),
5290 ToISODayOfYear(isolate, temporal_date->iso_year(),
5292 return handle(Smi::FromInt(value), isolate);
5297 Isolate* isolate, Handle<JSTemporalCalendar> calendar,
5306 isolate, temporal_date,
5307 ToTemporalDate(isolate, temporal_date_like,
5308 isolate->factory()->NewJSObjectWithNullProto(),
5314 ToISODayOfWeek(isolate, temporal_date->iso_year(),
5316 return handle(Smi::FromInt(value), isolate);
5321 Isolate* isolate, Handle<JSTemporalCalendar> calendar,
5333 isolate, temporal_date_like,
5334 ToTemporalDate(isolate, temporal_date_like,
5335 isolate->factory()->NewJSObjectWithNullProto(),
5343 return handle(Smi::FromInt(months_in_year), isolate);
5348 Isolate* isolate, Handle<JSTemporalCalendar> calendar,
5360 isolate, temporal_date_like,
5361 ToTemporalDate(isolate, temporal_date_like,
5362 isolate->factory()->NewJSObjectWithNullProto(),
5379 return isolate->factory()->ToBoolean(IsISOLeapYear(isolate, year));
5384 Isolate* isolate, Handle<JSTemporalCalendar> calendar,
5393 isolate, date,
5394 ToTemporalDate(isolate, temporal_date_like,
5395 isolate->factory()->NewJSObjectWithNullProto(),
5399 return handle(Smi::FromInt(7), isolate);
5404 Isolate* isolate, Handle<JSTemporalCalendar> calendar,
5413 THROW_NEW_ERROR(isolate,
5415 isolate->factory()->NewStringFromAsciiChecked(
5424 isolate, options, GetOptionsObject(isolate, options_obj, method_name),
5432 isolate, fields, options, method_name, &year, &month, &day);
5437 return CreateTemporalDate(isolate, year, month, day, calendar);
5445 Isolate* isolate, Handle<JSTemporalCalendar> calendar,
5453 ASSIGN_RETURN_ON_EXCEPTION(isolate, fields,
5454 Object::ToObject(isolate, fields_obj), JSReceiver);
5458 ASSIGN_RETURN_ON_EXCEPTION(isolate, additional_fields,
5459 Object::ToObject(isolate, additional_fields_obj),
5464 return DefaultMergeFields(isolate, fields, additional_fields);
5474 Isolate* isolate, Handle<JSTemporalCalendar> calendar,
5476 return CalendarIdentifier(isolate, calendar->calendar_index());
5480 MaybeHandle<JSTemporalTimeZone> JSTemporalTimeZone::Now(Isolate* isolate) {
5481 return SystemTimeZone(isolate);
5486 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
5489 if (new_target->IsUndefined(isolate)) {
5491 THROW_NEW_ERROR(isolate,
5493 isolate->factory()->NewStringFromAsciiChecked(
5499 ASSIGN_RETURN_ON_EXCEPTION(isolate, identifier,
5500 Object::ToString(isolate, identifier_obj),
5506 IsValidTimeZoneNumericUTCOffsetString(isolate, identifier);
5512 ParseTimeZoneOffsetString(isolate, identifier);
5518 isolate, canonical,
5519 FormatTimeZoneOffsetString(isolate, offset_nanoseconds),
5524 if (!IsValidTimeZoneName(isolate, identifier)) {
5527 isolate, NewRangeError(MessageTemplate::kInvalidTimeZone, identifier),
5531 ASSIGN_RETURN_ON_EXCEPTION(isolate, canonical,
5532 CanonicalizeTimeZoneName(isolate, identifier),
5536 return CreateTemporalTimeZone(isolate, target, new_target, canonical);
5541 Isolate* isolate, Handle<JSTemporalTimeZone> time_zone,
5543 return time_zone->id(isolate);
5562 MaybeHandle<String> JSTemporalTimeZone::id(Isolate* isolate) const {
5564 return FormatTimeZoneOffsetString(isolate, offset_nanoseconds());
5569 return isolate->factory()->NewStringFromAsciiChecked(id.c_str());
5572 return isolate->factory()->UTC_string();
5577 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
5583 THROW_NEW_ERROR(isolate,
5585 isolate->factory()->NewStringFromAsciiChecked(
5594 ASSIGN_RETURN_ON_EXCEPTION(isolate, number_##name, \
5595 ToIntegerThrowOnInfinity(isolate, name##_obj), \
5607 isolate, calendar,
5608 ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
5612 return CreateTemporalDate(isolate, target, new_target, iso_year, iso_month,
5618 Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date,
5627 isolate, calendar,
5628 temporal::ToTemporalCalendar(isolate, calendar_like, method_name),
5632 return CreateTemporalDate(isolate, temporal_date->iso_year(),
5639 Isolate* isolate, Handle<Object> calendar_like,
5644 ASSIGN_RETURN_ON_EXCEPTION(isolate, date_time,
5645 SystemDateTime(isolate, temporal_time_zone_like,
5650 return CreateTemporalDate(isolate, date_time->iso_year(),
5652 Handle<JSReceiver>(date_time->calendar(), isolate));
5657 Isolate* isolate, Handle<Object> temporal_time_zone_like) {
5661 ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
5662 temporal::GetISO8601Calendar(isolate),
5667 isolate, date_time,
5668 SystemDateTime(isolate, temporal_time_zone_like, calendar, method_name),
5672 return CreateTemporalDate(isolate, date_time->iso_year(),
5674 Handle<JSReceiver>(date_time->calendar(), isolate));
5679 Isolate* isolate, Handle<Object> item, Handle<Object> options_obj) {
5684 isolate, options, GetOptionsObject(isolate, options_obj, method_name),
5691 ToTemporalOverflow(isolate, options, method_name);
5696 return CreateTemporalDate(isolate, date->iso_year(), date->iso_month(),
5698 Handle<JSReceiver>(date->calendar(), isolate));
5701 return ToTemporalDate(isolate, item, options, method_name);
5706 isolate, obj, factory->str##_string(), \
5707 Handle<Smi>(Smi::FromInt(item->field()), isolate), \
5713 Isolate* isolate, Handle<JSTemporalPlainDate> temporal_date) {
5714 Factory* factory = isolate->factory();
5720 isolate->factory()->NewJSObject(isolate->object_function());
5724 isolate, fields, factory->calendar_string(),
5725 Handle<JSReceiver>(temporal_date->calendar(), isolate),
5743 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
5752 THROW_NEW_ERROR(isolate,
5754 isolate->factory()->NewStringFromAsciiChecked(
5772 isolate, calendar,
5773 ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
5778 return CreateTemporalDateTime(isolate, target, new_target, iso_year,
5785 Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time,
5794 isolate, calendar,
5795 temporal::ToTemporalCalendar(isolate, calendar_like, method_name),
5804 isolate, date_time->iso_year(), date_time->iso_month(),
5812 Isolate* isolate, Handle<Object> calendar_like,
5816 return SystemDateTime(isolate, temporal_time_zone_like, calendar_like,
5822 Isolate* isolate, Handle<Object> temporal_time_zone_like) {
5826 ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
5827 temporal::GetISO8601Calendar(isolate),
5830 return SystemDateTime(isolate, temporal_time_zone_like, calendar,
5836 Isolate* isolate, Handle<JSTemporalPlainDateTime> date_time) {
5837 Factory* factory = isolate->factory();
5843 isolate->factory()->NewJSObject(isolate->object_function());
5847 isolate, fields, factory->calendar_string(),
5848 Handle<JSReceiver>(date_time->calendar(), isolate),
5884 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
5890 THROW_NEW_ERROR(isolate,
5892 isolate->factory()->NewStringFromAsciiChecked(
5904 isolate, calendar,
5905 ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
5919 return CreateTemporalMonthDay(isolate, target, new_target, iso_month, iso_day,
5925 Isolate* isolate, Handle<JSTemporalPlainMonthDay> month_day) {
5926 Factory* factory = isolate->factory();
5931 Handle<JSObject> fields = factory->NewJSObject(isolate->object_function());
5935 isolate, fields, factory->calendar_string(),
5936 Handle<JSReceiver>(month_day->calendar(), isolate),
5954 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
5960 THROW_NEW_ERROR(isolate,
5962 isolate->factory()->NewStringFromAsciiChecked(
5976 isolate, calendar,
5977 ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
5991 return CreateTemporalYearMonth(isolate, target, new_target, iso_year,
5997 Isolate* isolate, Handle<JSTemporalPlainYearMonth> year_month) {
5998 Factory* factory = isolate->factory();
6004 isolate->factory()->NewJSObject(isolate->object_function());
6008 isolate, fields, factory->calendar_string(),
6009 Handle<JSReceiver>(year_month->calendar(), isolate),
6027 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
6036 THROW_NEW_ERROR(isolate,
6038 isolate->factory()->NewStringFromAsciiChecked(
6052 return CreateTemporalTime(isolate, target, new_target, hour, minute, second,
6058 Isolate* isolate, Handle<Object> temporal_time_zone_like) {
6062 ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
6063 temporal::GetISO8601Calendar(isolate),
6068 isolate, date_time,
6069 SystemDateTime(isolate, temporal_time_zone_like, calendar, method_name),
6076 isolate, date_time->iso_hour(), date_time->iso_minute(),
6083 Isolate* isolate, Handle<Object> item_obj, Handle<Object> options_obj) {
6088 isolate, options, GetOptionsObject(isolate, options_obj, method_name),
6092 ToTemporalOverflow(isolate, options, method_name);
6103 return CreateTemporalTime(isolate, item->iso_hour(), item->iso_minute(),
6108 return temporal::ToTemporalTime(isolate, item_obj, overflow, method_name);
6113 Isolate* isolate, Handle<JSTemporalPlainTime> temporal_time) {
6114 Factory* factory = isolate->factory();
6120 isolate->factory()->NewJSObject(isolate->object_function());
6124 ASSIGN_RETURN_ON_EXCEPTION(isolate, iso8601_calendar,
6125 temporal::GetISO8601Calendar(isolate),
6127 CHECK(JSReceiver::CreateDataProperty(isolate, fields,
6156 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
6163 THROW_NEW_ERROR(isolate,
6165 isolate->factory()->NewStringFromAsciiChecked(
6171 ASSIGN_RETURN_ON_EXCEPTION(isolate, epoch_nanoseconds,
6172 BigInt::FromObject(isolate, epoch_nanoseconds_obj),
6176 if (!IsValidEpochNanoseconds(isolate, epoch_nanoseconds)) {
6177 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
6184 isolate, time_zone,
6185 temporal::ToTemporalTimeZone(isolate, time_zone_like, method_name),
6191 isolate, calendar,
6192 ToTemporalCalendarWithISODefault(isolate, calendar_like, method_name),
6197 return CreateTemporalZonedDateTime(isolate, target, new_target,
6203 Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time,
6213 isolate, calendar,
6214 temporal::ToTemporalCalendar(isolate, calendar_like, method_name),
6219 Handle<BigInt> nanoseconds = handle(zoned_date_time->nanoseconds(), isolate);
6220 Handle<JSReceiver> time_zone = handle(zoned_date_time->time_zone(), isolate);
6221 return CreateTemporalZonedDateTime(isolate, nanoseconds, time_zone, calendar);
6226 Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time,
6236 isolate, time_zone,
6237 temporal::ToTemporalTimeZone(isolate, time_zone_like, method_name),
6242 Handle<BigInt> nanoseconds = handle(zoned_date_time->nanoseconds(), isolate);
6243 Handle<JSReceiver> calendar = handle(zoned_date_time->calendar(), isolate);
6244 return CreateTemporalZonedDateTime(isolate, nanoseconds, time_zone, calendar);
6253 Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time,
6257 Factory* factory = isolate->factory();
6262 Handle<JSReceiver> time_zone = handle(zoned_date_time->time_zone(), isolate);
6266 isolate, instant,
6268 isolate, Handle<BigInt>(zoned_date_time->nanoseconds(), isolate)),
6271 Handle<JSReceiver> calendar = handle(zoned_date_time->calendar(), isolate);
6276 isolate, temporal_date_time,
6277 temporal::BuiltinTimeZoneGetPlainDateTimeFor(isolate, time_zone, instant,
6285 ASSIGN_RETURN_ON_EXCEPTION(isolate, field_names,
6286 CalendarFields(isolate, calendar, field_names), T);
6290 isolate, fields,
6291 PrepareTemporalFields(isolate, temporal_date_time, field_names,
6295 return from_fields_func(isolate, calendar, fields,
6301 Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time) {
6304 isolate, zoned_date_time, isolate->factory()->monthCode_string(),
6305 isolate->factory()->year_string(),
6311 Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time) {
6314 isolate, zoned_date_time, isolate->factory()->day_string(),
6315 isolate->factory()->monthCode_string(),
6321 Isolate* isolate, Handle<Object> calendar_like,
6325 return SystemZonedDateTime(isolate, temporal_time_zone_like, calendar_like,
6331 Isolate* isolate, Handle<Object> temporal_time_zone_like) {
6336 ASSIGN_RETURN_ON_EXCEPTION(isolate, calendar,
6337 temporal::GetISO8601Calendar(isolate),
6340 return SystemZonedDateTime(isolate, temporal_time_zone_like, calendar,
6346 Isolate* isolate, Handle<JSTemporalZonedDateTime> zoned_date_time) {
6349 Factory* factory = isolate->factory();
6355 isolate->factory()->NewJSObject(isolate->object_function());
6358 Handle<JSReceiver>(zoned_date_time->time_zone(), isolate);
6362 isolate, instant,
6364 isolate, Handle<BigInt>(zoned_date_time->nanoseconds(), isolate)),
6369 Handle<JSReceiver>(zoned_date_time->calendar(), isolate);
6374 isolate, date_time,
6375 temporal::BuiltinTimeZoneGetPlainDateTimeFor(isolate, time_zone, instant,
6380 ASSIGN_RETURN_ON_EXCEPTION(isolate, offset,
6382 isolate, time_zone, instant, method_name),
6386 CHECK(JSReceiver::CreateDataProperty(isolate, obj, factory->str##_string(), \
6428 MaybeHandle<JSTemporalInstant> JSTemporalInstant::Now(Isolate* isolate) {
6430 return SystemInstant(isolate);
6435 Isolate* isolate, Handle<JSFunction> target, Handle<HeapObject> new_target,
6442 THROW_NEW_ERROR(isolate,
6444 isolate->factory()->NewStringFromAsciiChecked(
6450 ASSIGN_RETURN_ON_EXCEPTION(isolate, epoch_nanoseconds,
6451 BigInt::FromObject(isolate, epoch_nanoseconds_obj),
6455 if (!IsValidEpochNanoseconds(isolate, epoch_nanoseconds)) {
6456 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
6460 return temporal::CreateTemporalInstant(isolate, target, new_target,
6470 Isolate* isolate, Handle<BigInt> bigint, uint32_t scale) {
6480 isolate, epoch_nanoseconds,
6481 BigInt::Multiply(isolate, BigInt::FromUint64(isolate, scale), bigint),
6486 if (!IsValidEpochNanoseconds(isolate, epoch_nanoseconds)) {
6487 THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALD_ARG_RANGE_ERROR(),
6490 return temporal::CreateTemporalInstant(isolate, epoch_nanoseconds);
6494 Isolate* isolate, Handle<Object> epoch_Xseconds, uint32_t scale) {
6497 ASSIGN_RETURN_ON_EXCEPTION(isolate, epoch_Xseconds,
6498 Object::ToNumber(isolate, epoch_Xseconds),
6502 ASSIGN_RETURN_ON_EXCEPTION(isolate, bigint,
6503 BigInt::FromNumber(isolate, epoch_Xseconds),
6505 return ScaleNumberToNanosecondsVerifyAndMake(isolate, bigint, scale);
6509 Isolate* isolate, Handle<Object> epoch_Xseconds, uint32_t scale) {
6513 ASSIGN_RETURN_ON_EXCEPTION(isolate, bigint,
6514 BigInt::FromObject(isolate, epoch_Xseconds),
6516 return ScaleNumberToNanosecondsVerifyAndMake(isolate, bigint, scale);
6523 Isolate* isolate, Handle<Object> epoch_seconds) {
6525 return ScaleNumberToNanosecondsVerifyAndMake(isolate, epoch_seconds,
6531 Isolate* isolate, Handle<Object> epoch_milliseconds) {
6533 return ScaleNumberToNanosecondsVerifyAndMake(isolate, epoch_milliseconds,
6539 Isolate* isolate, Handle<Object> epoch_microseconds) {
6541 return ScaleToNanosecondsVerifyAndMake(isolate, epoch_microseconds, 1000);
6546 Isolate* isolate, Handle<Object> epoch_nanoseconds) {
6548 return ScaleToNanosecondsVerifyAndMake(isolate, epoch_nanoseconds, 1);
6552 MaybeHandle<JSTemporalInstant> JSTemporalInstant::From(Isolate* isolate,
6561 isolate, handle(JSTemporalInstant::cast(*item).nanoseconds(), isolate));
6564 return ToTemporalInstant(isolate, item, method_name);