1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:27:35 +00:00

LibJS: Convert Temporal.ZonedDateTime functions to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-10-21 20:19:48 +01:00
parent 7085458a23
commit 9143d37907
2 changed files with 195 additions and 196 deletions

View file

@ -33,74 +33,74 @@ void ZonedDateTimePrototype::initialize(GlobalObject& global_object)
// 6.3.2 Temporal.ZonedDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype-@@tostringtag // 6.3.2 Temporal.ZonedDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.ZonedDateTime"), Attribute::Configurable); define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.ZonedDateTime"), Attribute::Configurable);
define_old_native_accessor(vm.names.calendar, calendar_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.timeZone, time_zone_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.timeZone, time_zone_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.year, year_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.year, year_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.month, month_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.month, month_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.monthCode, month_code_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.monthCode, month_code_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.day, day_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.day, day_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.hour, hour_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.hour, hour_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.minute, minute_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.minute, minute_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.second, second_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.second, second_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.millisecond, millisecond_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.millisecond, millisecond_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.microsecond, microsecond_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.microsecond, microsecond_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.nanosecond, nanosecond_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.nanosecond, nanosecond_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.epochSeconds, epoch_seconds_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.epochSeconds, epoch_seconds_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.epochMilliseconds, epoch_milliseconds_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.epochMilliseconds, epoch_milliseconds_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.epochMicroseconds, epoch_microseconds_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.epochMicroseconds, epoch_microseconds_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.epochNanoseconds, epoch_nanoseconds_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.epochNanoseconds, epoch_nanoseconds_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.dayOfWeek, day_of_week_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.dayOfWeek, day_of_week_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.dayOfYear, day_of_year_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.dayOfYear, day_of_year_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.weekOfYear, week_of_year_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.weekOfYear, week_of_year_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.daysInWeek, days_in_week_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.daysInWeek, days_in_week_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.daysInMonth, days_in_month_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.daysInMonth, days_in_month_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.daysInYear, days_in_year_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.daysInYear, days_in_year_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.monthsInYear, months_in_year_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.monthsInYear, months_in_year_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.inLeapYear, in_leap_year_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.inLeapYear, in_leap_year_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.offsetNanoseconds, offset_nanoseconds_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.offsetNanoseconds, offset_nanoseconds_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.offset, offset_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.offset, offset_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.era, era_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.era, era_getter, {}, Attribute::Configurable);
define_old_native_accessor(vm.names.eraYear, era_year_getter, {}, Attribute::Configurable); define_native_accessor(vm.names.eraYear, era_year_getter, {}, Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable; u8 attr = Attribute::Writable | Attribute::Configurable;
define_old_native_function(vm.names.valueOf, value_of, 0, attr); define_native_function(vm.names.valueOf, value_of, 0, attr);
define_old_native_function(vm.names.toInstant, to_instant, 0, attr); define_native_function(vm.names.toInstant, to_instant, 0, attr);
define_old_native_function(vm.names.toPlainDate, to_plain_date, 0, attr); define_native_function(vm.names.toPlainDate, to_plain_date, 0, attr);
define_old_native_function(vm.names.toPlainTime, to_plain_time, 0, attr); define_native_function(vm.names.toPlainTime, to_plain_time, 0, attr);
define_old_native_function(vm.names.toPlainDateTime, to_plain_date_time, 0, attr); define_native_function(vm.names.toPlainDateTime, to_plain_date_time, 0, attr);
define_old_native_function(vm.names.toPlainYearMonth, to_plain_year_month, 0, attr); define_native_function(vm.names.toPlainYearMonth, to_plain_year_month, 0, attr);
define_old_native_function(vm.names.toPlainMonthDay, to_plain_month_day, 0, attr); define_native_function(vm.names.toPlainMonthDay, to_plain_month_day, 0, attr);
define_old_native_function(vm.names.getISOFields, get_iso_fields, 0, attr); define_native_function(vm.names.getISOFields, get_iso_fields, 0, attr);
} }
// 6.3.3 get Temporal.ZonedDateTime.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.calendar // 6.3.3 get Temporal.ZonedDateTime.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.calendar
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::calendar_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::calendar_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Return zonedDateTime.[[Calendar]]. // 3. Return zonedDateTime.[[Calendar]].
return Value(&zoned_date_time->calendar()); return Value(&zoned_date_time->calendar());
} }
// 6.3.4 get Temporal.ZonedDateTime.prototype.timeZone, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.timezone // 6.3.4 get Temporal.ZonedDateTime.prototype.timeZone, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.timezone
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::time_zone_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::time_zone_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Return zonedDateTime.[[TimeZone]]. // 3. Return zonedDateTime.[[TimeZone]].
return Value(&zoned_date_time->time_zone()); return Value(&zoned_date_time->time_zone());
} }
// 6.3.5 get Temporal.ZonedDateTime.prototype.year, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.year // 6.3.5 get Temporal.ZonedDateTime.prototype.year, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.year
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::year_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::year_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -112,18 +112,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::year_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarYear(calendar, temporalDateTime). // 7. Return ? CalendarYear(calendar, temporalDateTime).
return Value(TRY_OR_DISCARD(calendar_year(global_object, calendar, *temporal_date_time))); return Value(TRY(calendar_year(global_object, calendar, *temporal_date_time)));
} }
// 6.3.6 get Temporal.ZonedDateTime.prototype.month, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.month // 6.3.6 get Temporal.ZonedDateTime.prototype.month, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.month
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::month_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::month_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -135,18 +135,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::month_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarMonth(calendar, temporalDateTime). // 7. Return ? CalendarMonth(calendar, temporalDateTime).
return Value(TRY_OR_DISCARD(calendar_month(global_object, calendar, *temporal_date_time))); return Value(TRY(calendar_month(global_object, calendar, *temporal_date_time)));
} }
// 6.3.7 get Temporal.ZonedDateTime.prototype.monthCode, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.monthcode // 6.3.7 get Temporal.ZonedDateTime.prototype.monthCode, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.monthcode
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::month_code_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::month_code_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -158,18 +158,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::month_code_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarMonthCode(calendar, temporalDateTime). // 7. Return ? CalendarMonthCode(calendar, temporalDateTime).
return js_string(vm, TRY_OR_DISCARD(calendar_month_code(global_object, calendar, *temporal_date_time))); return js_string(vm, TRY(calendar_month_code(global_object, calendar, *temporal_date_time)));
} }
// 6.3.8 get Temporal.ZonedDateTime.prototype.day, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.day // 6.3.8 get Temporal.ZonedDateTime.prototype.day, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.day
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::day_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::day_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -181,18 +181,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::day_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarDay(calendar, temporalDateTime). // 7. Return ? CalendarDay(calendar, temporalDateTime).
return Value(TRY_OR_DISCARD(calendar_day(global_object, calendar, *temporal_date_time))); return Value(TRY(calendar_day(global_object, calendar, *temporal_date_time)));
} }
// 6.3.9 get Temporal.ZonedDateTime.prototype.hour, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.hour // 6.3.9 get Temporal.ZonedDateTime.prototype.hour, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.hour
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::hour_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::hour_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -204,18 +204,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::hour_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return 𝔽(temporalDateTime.[[ISOHour]]). // 7. Return 𝔽(temporalDateTime.[[ISOHour]]).
return Value(temporal_date_time->iso_hour()); return Value(temporal_date_time->iso_hour());
} }
// 6.3.10 get Temporal.ZonedDateTime.prototype.minute, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.minute // 6.3.10 get Temporal.ZonedDateTime.prototype.minute, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.minute
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::minute_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::minute_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -227,18 +227,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::minute_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return 𝔽(temporalDateTime.[[ISOMinute]]). // 7. Return 𝔽(temporalDateTime.[[ISOMinute]]).
return Value(temporal_date_time->iso_minute()); return Value(temporal_date_time->iso_minute());
} }
// 6.3.11 get Temporal.ZonedDateTime.prototype.second, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.second // 6.3.11 get Temporal.ZonedDateTime.prototype.second, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.second
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::second_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::second_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -250,18 +250,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::second_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return 𝔽(temporalDateTime.[[ISOSecond]]). // 7. Return 𝔽(temporalDateTime.[[ISOSecond]]).
return Value(temporal_date_time->iso_second()); return Value(temporal_date_time->iso_second());
} }
// 6.3.12 get Temporal.ZonedDateTime.prototype.millisecond, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.millisecond // 6.3.12 get Temporal.ZonedDateTime.prototype.millisecond, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.millisecond
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::millisecond_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::millisecond_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -273,18 +273,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::millisecond_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return 𝔽(temporalDateTime.[[ISOMillisecond]]). // 7. Return 𝔽(temporalDateTime.[[ISOMillisecond]]).
return Value(temporal_date_time->iso_millisecond()); return Value(temporal_date_time->iso_millisecond());
} }
// 6.3.13 get Temporal.ZonedDateTime.prototype.microsecond, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.microsecond // 6.3.13 get Temporal.ZonedDateTime.prototype.microsecond, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.microsecond
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::microsecond_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::microsecond_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -296,18 +296,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::microsecond_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return 𝔽(temporalDateTime.[[ISOMicrosecond]]). // 7. Return 𝔽(temporalDateTime.[[ISOMicrosecond]]).
return Value(temporal_date_time->iso_microsecond()); return Value(temporal_date_time->iso_microsecond());
} }
// 6.3.14 get Temporal.ZonedDateTime.prototype.nanosecond, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.nanosecond // 6.3.14 get Temporal.ZonedDateTime.prototype.nanosecond, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.nanosecond
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::nanosecond_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::nanosecond_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -319,18 +319,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::nanosecond_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return 𝔽(temporalDateTime.[[ISONanosecond]]). // 7. Return 𝔽(temporalDateTime.[[ISONanosecond]]).
return Value(temporal_date_time->iso_nanosecond()); return Value(temporal_date_time->iso_nanosecond());
} }
// 6.3.15 get Temporal.ZonedDateTime.prototype.epochSeconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.epochseconds // 6.3.15 get Temporal.ZonedDateTime.prototype.epochSeconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.epochseconds
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_seconds_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_seconds_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let ns be zonedDateTime.[[Nanoseconds]]. // 3. Let ns be zonedDateTime.[[Nanoseconds]].
auto& ns = zoned_date_time->nanoseconds(); auto& ns = zoned_date_time->nanoseconds();
@ -343,11 +343,11 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_seconds_getter)
} }
// 6.3.16 get Temporal.ZonedDateTime.prototype.epochMilliseconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.epochmilliseconds // 6.3.16 get Temporal.ZonedDateTime.prototype.epochMilliseconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.epochmilliseconds
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_milliseconds_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_milliseconds_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let ns be zonedDateTime.[[Nanoseconds]]. // 3. Let ns be zonedDateTime.[[Nanoseconds]].
auto& ns = zoned_date_time->nanoseconds(); auto& ns = zoned_date_time->nanoseconds();
@ -360,11 +360,11 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_milliseconds_getter)
} }
// 6.3.17 get Temporal.ZonedDateTime.prototype.epochMicroseconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.epochmicroseconds // 6.3.17 get Temporal.ZonedDateTime.prototype.epochMicroseconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.epochmicroseconds
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_microseconds_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_microseconds_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let ns be zonedDateTime.[[Nanoseconds]]. // 3. Let ns be zonedDateTime.[[Nanoseconds]].
auto& ns = zoned_date_time->nanoseconds(); auto& ns = zoned_date_time->nanoseconds();
@ -377,22 +377,22 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_microseconds_getter)
} }
// 6.3.18 get Temporal.ZonedDateTime.prototype.epochNanoseconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.epochnanoseconds // 6.3.18 get Temporal.ZonedDateTime.prototype.epochNanoseconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.epochnanoseconds
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_nanoseconds_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_nanoseconds_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Return zonedDateTime.[[Nanoseconds]]. // 3. Return zonedDateTime.[[Nanoseconds]].
return &zoned_date_time->nanoseconds(); return &zoned_date_time->nanoseconds();
} }
// 6.3.19 get Temporal.ZonedDateTime.prototype.dayOfWeek, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.dayofweek // 6.3.19 get Temporal.ZonedDateTime.prototype.dayOfWeek, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.dayofweek
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::day_of_week_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::day_of_week_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -404,18 +404,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::day_of_week_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarDayOfWeek(calendar, temporalDateTime). // 7. Return ? CalendarDayOfWeek(calendar, temporalDateTime).
return TRY_OR_DISCARD(calendar_day_of_week(global_object, calendar, *temporal_date_time)); return TRY(calendar_day_of_week(global_object, calendar, *temporal_date_time));
} }
// 6.3.20 get Temporal.ZonedDateTime.prototype.dayOfYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.dayofyear // 6.3.20 get Temporal.ZonedDateTime.prototype.dayOfYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.dayofyear
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::day_of_year_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::day_of_year_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -427,18 +427,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::day_of_year_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarDayOfYear(calendar, temporalDateTime). // 7. Return ? CalendarDayOfYear(calendar, temporalDateTime).
return TRY_OR_DISCARD(calendar_day_of_year(global_object, calendar, *temporal_date_time)); return TRY(calendar_day_of_year(global_object, calendar, *temporal_date_time));
} }
// 6.3.21 get Temporal.ZonedDateTime.prototype.weekOfYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.weekofyear // 6.3.21 get Temporal.ZonedDateTime.prototype.weekOfYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.weekofyear
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::week_of_year_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::week_of_year_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -450,18 +450,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::week_of_year_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarWeekOfYear(calendar, temporalDateTime). // 7. Return ? CalendarWeekOfYear(calendar, temporalDateTime).
return TRY_OR_DISCARD(calendar_week_of_year(global_object, calendar, *temporal_date_time)); return TRY(calendar_week_of_year(global_object, calendar, *temporal_date_time));
} }
// 6.3.23 get Temporal.ZonedDateTime.prototype.daysInWeek, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.daysinweek // 6.3.23 get Temporal.ZonedDateTime.prototype.daysInWeek, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.daysinweek
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_week_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_week_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -473,18 +473,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_week_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarDaysInWeek(calendar, temporalDateTime). // 7. Return ? CalendarDaysInWeek(calendar, temporalDateTime).
return TRY_OR_DISCARD(calendar_days_in_week(global_object, calendar, *temporal_date_time)); return TRY(calendar_days_in_week(global_object, calendar, *temporal_date_time));
} }
// 6.3.24 get Temporal.ZonedDateTime.prototype.daysInMonth, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.daysinmonth // 6.3.24 get Temporal.ZonedDateTime.prototype.daysInMonth, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.daysinmonth
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_month_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_month_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -496,18 +496,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_month_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarDaysInMonth(calendar, temporalDateTime). // 7. Return ? CalendarDaysInMonth(calendar, temporalDateTime).
return TRY_OR_DISCARD(calendar_days_in_month(global_object, calendar, *temporal_date_time)); return TRY(calendar_days_in_month(global_object, calendar, *temporal_date_time));
} }
// 6.3.25 get Temporal.ZonedDateTime.prototype.daysInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.daysinyear // 6.3.25 get Temporal.ZonedDateTime.prototype.daysInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.daysinyear
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_year_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_year_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -519,18 +519,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_year_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarDaysInYear(calendar, temporalDateTime). // 7. Return ? CalendarDaysInYear(calendar, temporalDateTime).
return TRY_OR_DISCARD(calendar_days_in_year(global_object, calendar, *temporal_date_time)); return TRY(calendar_days_in_year(global_object, calendar, *temporal_date_time));
} }
// 6.3.26 get Temporal.ZonedDateTime.prototype.monthsInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.monthsinyear // 6.3.26 get Temporal.ZonedDateTime.prototype.monthsInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.monthsinyear
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::months_in_year_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::months_in_year_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -542,18 +542,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::months_in_year_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarMonthsInYear(calendar, temporalDateTime). // 7. Return ? CalendarMonthsInYear(calendar, temporalDateTime).
return TRY_OR_DISCARD(calendar_months_in_year(global_object, calendar, *temporal_date_time)); return TRY(calendar_months_in_year(global_object, calendar, *temporal_date_time));
} }
// 6.3.27 get Temporal.ZonedDateTime.prototype.inLeapYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.inleapyear // 6.3.27 get Temporal.ZonedDateTime.prototype.inLeapYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.inleapyear
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::in_leap_year_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::in_leap_year_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -565,18 +565,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::in_leap_year_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarInLeapYear(calendar, temporalDateTime). // 7. Return ? CalendarInLeapYear(calendar, temporalDateTime).
return TRY_OR_DISCARD(calendar_in_leap_year(global_object, calendar, *temporal_date_time)); return TRY(calendar_in_leap_year(global_object, calendar, *temporal_date_time));
} }
// 6.3.28 get Temporal.ZonedDateTime.prototype.offsetNanoseconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.offsetnanoseconds // 6.3.28 get Temporal.ZonedDateTime.prototype.offsetNanoseconds, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.offsetnanoseconds
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_nanoseconds_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_nanoseconds_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -585,30 +585,30 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_nanoseconds_getter)
auto* instant = MUST(create_temporal_instant(global_object, zoned_date_time->nanoseconds())); auto* instant = MUST(create_temporal_instant(global_object, zoned_date_time->nanoseconds()));
// 5. Return 𝔽(? GetOffsetNanosecondsFor(timeZone, instant)). // 5. Return 𝔽(? GetOffsetNanosecondsFor(timeZone, instant)).
return Value(TRY_OR_DISCARD(get_offset_nanoseconds_for(global_object, &time_zone, *instant))); return Value(TRY(get_offset_nanoseconds_for(global_object, &time_zone, *instant)));
} }
// 6.3.29 get Temporal.ZonedDateTime.prototype.offset, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.offset // 6.3.29 get Temporal.ZonedDateTime.prototype.offset, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.offset
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]). // 3. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
auto* instant = MUST(create_temporal_instant(global_object, zoned_date_time->nanoseconds())); auto* instant = MUST(create_temporal_instant(global_object, zoned_date_time->nanoseconds()));
// 4. Return ? BuiltinTimeZoneGetOffsetStringFor(zonedDateTime.[[TimeZone]], instant). // 4. Return ? BuiltinTimeZoneGetOffsetStringFor(zonedDateTime.[[TimeZone]], instant).
auto offset_string = TRY_OR_DISCARD(builtin_time_zone_get_offset_string_for(global_object, &zoned_date_time->time_zone(), *instant)); auto offset_string = TRY(builtin_time_zone_get_offset_string_for(global_object, &zoned_date_time->time_zone(), *instant));
return js_string(vm, move(offset_string)); return js_string(vm, move(offset_string));
} }
// 15.6.10.2 get Temporal.ZonedDateTime.prototype.era, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.era // 15.6.10.2 get Temporal.ZonedDateTime.prototype.era, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.era
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::era_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::era_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -620,18 +620,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::era_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let plainDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let plainDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* plain_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* plain_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarEra(calendar, plainDateTime). // 7. Return ? CalendarEra(calendar, plainDateTime).
return TRY_OR_DISCARD(calendar_era(global_object, calendar, *plain_date_time)); return TRY(calendar_era(global_object, calendar, *plain_date_time));
} }
// 15.6.10.3 get Temporal.ZonedDateTime.prototype.eraYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.erayear // 15.6.10.3 get Temporal.ZonedDateTime.prototype.eraYear, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.erayear
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::era_year_getter) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::era_year_getter)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -643,37 +643,36 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::era_year_getter)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let plainDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let plainDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* plain_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* plain_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CalendarEraYear(calendar, plainDateTime). // 7. Return ? CalendarEraYear(calendar, plainDateTime).
return TRY_OR_DISCARD(calendar_era_year(global_object, calendar, *plain_date_time)); return TRY(calendar_era_year(global_object, calendar, *plain_date_time));
} }
// 6.3.44 Temporal.ZonedDateTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.valueof // 6.3.44 Temporal.ZonedDateTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.valueof
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::value_of) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::value_of)
{ {
// 1. Throw a TypeError exception. // 1. Throw a TypeError exception.
vm.throw_exception<TypeError>(global_object, ErrorType::Convert, "Temporal.ZonedDateTime", "a primitive value"); return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.ZonedDateTime", "a primitive value");
return {};
} }
// 6.3.46 Temporal.ZonedDateTime.prototype.toInstant ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toinstant // 6.3.46 Temporal.ZonedDateTime.prototype.toInstant ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toinstant
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_instant) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_instant)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Return ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]). // 3. Return ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
return MUST(create_temporal_instant(global_object, zoned_date_time->nanoseconds())); return MUST(create_temporal_instant(global_object, zoned_date_time->nanoseconds()));
} }
// 6.3.47 Temporal.ZonedDateTime.prototype.toPlainDate ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplaindate // 6.3.47 Temporal.ZonedDateTime.prototype.toPlainDate ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplaindate
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_date) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_date)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -685,18 +684,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_date)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CreateTemporalDate(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], calendar). // 7. Return ? CreateTemporalDate(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], calendar).
return TRY_OR_DISCARD(create_temporal_date(global_object, temporal_date_time->iso_year(), temporal_date_time->iso_month(), temporal_date_time->iso_day(), calendar)); return TRY(create_temporal_date(global_object, temporal_date_time->iso_year(), temporal_date_time->iso_month(), temporal_date_time->iso_day(), calendar));
} }
// 6.3.48 Temporal.ZonedDateTime.prototype.toPlainTime ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplaintime // 6.3.48 Temporal.ZonedDateTime.prototype.toPlainTime ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplaintime
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_time) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_time)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -708,18 +707,18 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_time)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, zonedDateTime.[[Calendar]]). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, zonedDateTime.[[Calendar]]).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Return ? CreateTemporalTime(temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]]). // 7. Return ? CreateTemporalTime(temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]]).
return TRY_OR_DISCARD(create_temporal_time(global_object, temporal_date_time->iso_hour(), temporal_date_time->iso_minute(), temporal_date_time->iso_second(), temporal_date_time->iso_millisecond(), temporal_date_time->iso_microsecond(), temporal_date_time->iso_nanosecond())); return TRY(create_temporal_time(global_object, temporal_date_time->iso_hour(), temporal_date_time->iso_minute(), temporal_date_time->iso_second(), temporal_date_time->iso_millisecond(), temporal_date_time->iso_microsecond(), temporal_date_time->iso_nanosecond()));
} }
// 6.3.49 Temporal.ZonedDateTime.prototype.toPlainDateTime ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplaindatetime // 6.3.49 Temporal.ZonedDateTime.prototype.toPlainDateTime ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplaindatetime
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_date_time) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_date_time)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -728,15 +727,15 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_date_time)
auto* instant = MUST(create_temporal_instant(global_object, zoned_date_time->nanoseconds())); auto* instant = MUST(create_temporal_instant(global_object, zoned_date_time->nanoseconds()));
// 5. Return ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, zonedDateTime.[[Calendar]]). // 5. Return ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, zonedDateTime.[[Calendar]]).
return TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, zoned_date_time->calendar())); return TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, zoned_date_time->calendar()));
} }
// 6.3.50 Temporal.ZonedDateTime.prototype.toPlainYearMonth ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplainyearmonth // 6.3.50 Temporal.ZonedDateTime.prototype.toPlainYearMonth ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplainyearmonth
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_year_month) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_year_month)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -748,24 +747,24 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_year_month)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Let fieldNames be ? CalendarFields(calendar, « "monthCode", "year" »). // 7. Let fieldNames be ? CalendarFields(calendar, « "monthCode", "year" »).
auto field_names = TRY_OR_DISCARD(calendar_fields(global_object, calendar, { "monthCode"sv, "year"sv })); auto field_names = TRY(calendar_fields(global_object, calendar, { "monthCode"sv, "year"sv }));
// 8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»). // 8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
auto* fields = TRY_OR_DISCARD(prepare_temporal_fields(global_object, *temporal_date_time, field_names, {})); auto* fields = TRY(prepare_temporal_fields(global_object, *temporal_date_time, field_names, {}));
// 9. Return ? YearMonthFromFields(calendar, fields). // 9. Return ? YearMonthFromFields(calendar, fields).
return TRY_OR_DISCARD(year_month_from_fields(global_object, calendar, *fields)); return TRY(year_month_from_fields(global_object, calendar, *fields));
} }
// 6.3.51 Temporal.ZonedDateTime.prototype.toPlainMonthDay ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplainmonthday // 6.3.51 Temporal.ZonedDateTime.prototype.toPlainMonthDay ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplainmonthday
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_month_day) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_month_day)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let timeZone be zonedDateTime.[[TimeZone]]. // 3. Let timeZone be zonedDateTime.[[TimeZone]].
auto& time_zone = zoned_date_time->time_zone(); auto& time_zone = zoned_date_time->time_zone();
@ -777,24 +776,24 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_month_day)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* temporal_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 7. Let fieldNames be ? CalendarFields(calendar, « "day", "monthCode" »). // 7. Let fieldNames be ? CalendarFields(calendar, « "day", "monthCode" »).
auto field_names = TRY_OR_DISCARD(calendar_fields(global_object, calendar, { "day"sv, "monthCode"sv })); auto field_names = TRY(calendar_fields(global_object, calendar, { "day"sv, "monthCode"sv }));
// 8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»). // 8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
auto* fields = TRY_OR_DISCARD(prepare_temporal_fields(global_object, *temporal_date_time, field_names, {})); auto* fields = TRY(prepare_temporal_fields(global_object, *temporal_date_time, field_names, {}));
// 9. Return ? MonthDayFromFields(calendar, fields). // 9. Return ? MonthDayFromFields(calendar, fields).
return TRY_OR_DISCARD(month_day_from_fields(global_object, calendar, *fields)); return TRY(month_day_from_fields(global_object, calendar, *fields));
} }
// 6.3.52 Temporal.ZonedDateTime.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.getisofields // 6.3.52 Temporal.ZonedDateTime.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.getisofields
JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields)
{ {
// 1. Let zonedDateTime be the this value. // 1. Let zonedDateTime be the this value.
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto* zoned_date_time = TRY(typed_this_object(global_object));
// 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%). // 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%).
auto* fields = Object::create(global_object, global_object.object_prototype()); auto* fields = Object::create(global_object, global_object.object_prototype());
@ -809,10 +808,10 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields)
auto& calendar = zoned_date_time->calendar(); auto& calendar = zoned_date_time->calendar();
// 7. Let dateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar). // 7. Let dateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
auto* date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar)); auto* date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar));
// 8. Let offset be ? BuiltinTimeZoneGetOffsetStringFor(timeZone, instant). // 8. Let offset be ? BuiltinTimeZoneGetOffsetStringFor(timeZone, instant).
auto offset = TRY_OR_DISCARD(builtin_time_zone_get_offset_string_for(global_object, &time_zone, *instant)); auto offset = TRY(builtin_time_zone_get_offset_string_for(global_object, &time_zone, *instant));
// 9. Perform ! CreateDataPropertyOrThrow(fields, "calendar", calendar). // 9. Perform ! CreateDataPropertyOrThrow(fields, "calendar", calendar).
MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&calendar))); MUST(fields->create_data_property_or_throw(vm.names.calendar, Value(&calendar)));

View file

@ -20,42 +20,42 @@ public:
virtual ~ZonedDateTimePrototype() override = default; virtual ~ZonedDateTimePrototype() override = default;
private: private:
JS_DECLARE_OLD_NATIVE_FUNCTION(calendar_getter); JS_DECLARE_NATIVE_FUNCTION(calendar_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(time_zone_getter); JS_DECLARE_NATIVE_FUNCTION(time_zone_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(year_getter); JS_DECLARE_NATIVE_FUNCTION(year_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(month_getter); JS_DECLARE_NATIVE_FUNCTION(month_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(month_code_getter); JS_DECLARE_NATIVE_FUNCTION(month_code_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(day_getter); JS_DECLARE_NATIVE_FUNCTION(day_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(hour_getter); JS_DECLARE_NATIVE_FUNCTION(hour_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(minute_getter); JS_DECLARE_NATIVE_FUNCTION(minute_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(second_getter); JS_DECLARE_NATIVE_FUNCTION(second_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(millisecond_getter); JS_DECLARE_NATIVE_FUNCTION(millisecond_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(microsecond_getter); JS_DECLARE_NATIVE_FUNCTION(microsecond_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(nanosecond_getter); JS_DECLARE_NATIVE_FUNCTION(nanosecond_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(epoch_seconds_getter); JS_DECLARE_NATIVE_FUNCTION(epoch_seconds_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(epoch_milliseconds_getter); JS_DECLARE_NATIVE_FUNCTION(epoch_milliseconds_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(epoch_microseconds_getter); JS_DECLARE_NATIVE_FUNCTION(epoch_microseconds_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(epoch_nanoseconds_getter); JS_DECLARE_NATIVE_FUNCTION(epoch_nanoseconds_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(day_of_week_getter); JS_DECLARE_NATIVE_FUNCTION(day_of_week_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(day_of_year_getter); JS_DECLARE_NATIVE_FUNCTION(day_of_year_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(week_of_year_getter); JS_DECLARE_NATIVE_FUNCTION(week_of_year_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(days_in_week_getter); JS_DECLARE_NATIVE_FUNCTION(days_in_week_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(days_in_month_getter); JS_DECLARE_NATIVE_FUNCTION(days_in_month_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(days_in_year_getter); JS_DECLARE_NATIVE_FUNCTION(days_in_year_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(months_in_year_getter); JS_DECLARE_NATIVE_FUNCTION(months_in_year_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(in_leap_year_getter); JS_DECLARE_NATIVE_FUNCTION(in_leap_year_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(offset_nanoseconds_getter); JS_DECLARE_NATIVE_FUNCTION(offset_nanoseconds_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(offset_getter); JS_DECLARE_NATIVE_FUNCTION(offset_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(era_getter); JS_DECLARE_NATIVE_FUNCTION(era_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(era_year_getter); JS_DECLARE_NATIVE_FUNCTION(era_year_getter);
JS_DECLARE_OLD_NATIVE_FUNCTION(value_of); JS_DECLARE_NATIVE_FUNCTION(value_of);
JS_DECLARE_OLD_NATIVE_FUNCTION(to_instant); JS_DECLARE_NATIVE_FUNCTION(to_instant);
JS_DECLARE_OLD_NATIVE_FUNCTION(to_plain_date); JS_DECLARE_NATIVE_FUNCTION(to_plain_date);
JS_DECLARE_OLD_NATIVE_FUNCTION(to_plain_time); JS_DECLARE_NATIVE_FUNCTION(to_plain_time);
JS_DECLARE_OLD_NATIVE_FUNCTION(to_plain_date_time); JS_DECLARE_NATIVE_FUNCTION(to_plain_date_time);
JS_DECLARE_OLD_NATIVE_FUNCTION(to_plain_year_month); JS_DECLARE_NATIVE_FUNCTION(to_plain_year_month);
JS_DECLARE_OLD_NATIVE_FUNCTION(to_plain_month_day); JS_DECLARE_NATIVE_FUNCTION(to_plain_month_day);
JS_DECLARE_OLD_NATIVE_FUNCTION(get_iso_fields); JS_DECLARE_NATIVE_FUNCTION(get_iso_fields);
}; };
} }