LibJS: Reflect infallibility editorial changes in the Temporal spec

See:

- https://github.com/tc39/proposal-temporal/commit/3c0671f
- https://github.com/tc39/proposal-temporal/commit/fe28b86
This commit is contained in:
Linus Groh 2021-07-28 23:48:56 +01:00
parent 6340aa11ce
commit 4e4d8d6905
Notes: sideshowbarker 2024-07-18 07:56:50 +09:00
3 changed files with 10 additions and 16 deletions

View File

@ -81,7 +81,7 @@ Calendar* get_builtin_calendar(GlobalObject& global_object, String const& identi
// 12.1.4 GetISO8601Calendar ( )
Calendar* get_iso8601_calendar(GlobalObject& global_object)
{
// 1. Return ? GetBuiltinCalendar("iso8601").
// 1. Return ! GetBuiltinCalendar("iso8601").
return get_builtin_calendar(global_object, "iso8601");
}
@ -346,7 +346,7 @@ Object* to_temporal_calendar_with_iso_default(GlobalObject& global_object, Value
{
// 1. If temporalCalendarLike is undefined, then
if (temporal_calendar_like.is_undefined()) {
// a. Return ? GetISO8601Calendar().
// a. Return ! GetISO8601Calendar().
return get_iso8601_calendar(global_object);
}
// 2. Return ? ToTemporalCalendar(temporalCalendarLike).

View File

@ -71,10 +71,8 @@ JS_DEFINE_NATIVE_FUNCTION(Now::plain_date_time_iso)
{
auto temporal_time_zone_like = vm.argument(0);
// 1, Let calendar be ? GetISO8601Calendar().
// 1, Let calendar be ! GetISO8601Calendar().
auto* calendar = get_iso8601_calendar(global_object);
if (vm.exception())
return {};
// 2. Return ? SystemDateTime(temporalTimeZoneLike, calendar).
return system_date_time(global_object, temporal_time_zone_like, calendar);
@ -91,7 +89,7 @@ JS_DEFINE_NATIVE_FUNCTION(Now::plain_date)
if (vm.exception())
return {};
// 2. Return ? CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]).
// 2. Return ! CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]).
return create_temporal_date(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->calendar());
}
@ -100,17 +98,15 @@ JS_DEFINE_NATIVE_FUNCTION(Now::plain_date_iso)
{
auto temporal_time_zone_like = vm.argument(0);
// 1. Let calendar be ? GetISO8601Calendar().
// 1. Let calendar be ! GetISO8601Calendar().
auto* calendar = get_iso8601_calendar(global_object);
if (vm.exception())
return {};
// 2. Let dateTime be ? SystemDateTime(temporalTimeZoneLike, calendar).
auto* date_time = system_date_time(global_object, temporal_time_zone_like, calendar);
if (vm.exception())
return {};
// 3. Return ? CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]).
// 3. Return ! CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]).
return create_temporal_date(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->calendar());
}
@ -119,16 +115,15 @@ JS_DEFINE_NATIVE_FUNCTION(Now::plain_time_iso)
{
auto temporal_time_zone_like = vm.argument(0);
// 1. Let calendar be ? GetISO8601Calendar().
// NOTE: No exception check needed for GetISO8601Calendar, see https://github.com/tc39/proposal-temporal/pull/1643
// 1. Let calendar be ! GetISO8601Calendar().
auto* calendar = get_iso8601_calendar(global_object);
// 2. Let dateTime be ? SystemDateTime(temporalTimeZoneLike, calendar).
auto date_time = system_date_time(global_object, temporal_time_zone_like, calendar);
auto* date_time = system_date_time(global_object, temporal_time_zone_like, calendar);
if (vm.exception())
return {};
// 3. Return ? CreateTemporalTime(dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]).
// 3. Return ! CreateTemporalTime(dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]).
return create_temporal_time(global_object, date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond());
}

View File

@ -154,8 +154,7 @@ PlainTime* create_temporal_time(GlobalObject& global_object, u8 hour, u8 minute,
// 8. Set object.[[ISOMillisecond]] to millisecond.
// 9. Set object.[[ISOMicrosecond]] to microsecond.
// 10. Set object.[[ISONanosecond]] to nanosecond.
// 11. Set object.[[Calendar]] to ? GetISO8601Calendar().
// NOTE: No exception check needed for GetISO8601Calendar, see https://github.com/tc39/proposal-temporal/pull/1643
// 11. Set object.[[Calendar]] to ! GetISO8601Calendar().
auto* object = ordinary_create_from_constructor<PlainTime>(global_object, *new_target, &GlobalObject::temporal_plain_time_prototype, hour, minute, second, millisecond, microsecond, nanosecond, *get_iso8601_calendar(global_object));
if (vm.exception())
return {};