mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:27:45 +00:00
LibJS: Convert parse_temporal_date_string() to ThrowCompletionOr
This commit is contained in:
parent
2e28f0b371
commit
4cb6eaf588
3 changed files with 7 additions and 9 deletions
|
@ -139,20 +139,18 @@ PlainDate* to_temporal_date(GlobalObject& global_object, Value item, Object* opt
|
|||
return {};
|
||||
|
||||
// 6. Let result be ? ParseTemporalDateString(string).
|
||||
auto result = parse_temporal_date_string(global_object, string);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto result = TRY_OR_DISCARD(parse_temporal_date_string(global_object, string));
|
||||
|
||||
// 7. Assert: ! IsValidISODate(result.[[Year]], result.[[Month]], result.[[Day]]) is true.
|
||||
VERIFY(is_valid_iso_date(result->year, result->month, result->day));
|
||||
VERIFY(is_valid_iso_date(result.year, result.month, result.day));
|
||||
|
||||
// 8. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]).
|
||||
auto calendar = to_temporal_calendar_with_iso_default(global_object, result->calendar.has_value() ? js_string(vm, *result->calendar) : js_undefined());
|
||||
auto calendar = to_temporal_calendar_with_iso_default(global_object, result.calendar.has_value() ? js_string(vm, *result.calendar) : js_undefined());
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
// 9. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).
|
||||
return create_temporal_date(global_object, result->year, result->month, result->day, *calendar);
|
||||
return create_temporal_date(global_object, result.year, result.month, result.day, *calendar);
|
||||
}
|
||||
|
||||
// 3.5.4 RegulateISODate ( year, month, day, overflow ), https://tc39.es/proposal-temporal/#sec-temporal-regulateisodate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue