mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
LibJS: Convert parse_temporal_time_string() to ThrowCompletionOr
This commit is contained in:
parent
f86fa12deb
commit
0ccd11ba5f
Notes:
sideshowbarker
2024-07-18 03:48:28 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/0ccd11ba5f2 Pull-request: https://github.com/SerenityOS/serenity/pull/10065 Reviewed-by: https://github.com/IdanHo ✅
@ -900,7 +900,7 @@ ThrowCompletionOr<TemporalDuration> parse_temporal_duration_string(GlobalObject&
|
||||
}
|
||||
|
||||
// 13.43 ParseTemporalTimeString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaltimestring
|
||||
Optional<TemporalTime> parse_temporal_time_string(GlobalObject& global_object, [[maybe_unused]] String const& iso_string)
|
||||
ThrowCompletionOr<TemporalTime> parse_temporal_time_string(GlobalObject& global_object, [[maybe_unused]] String const& iso_string)
|
||||
{
|
||||
// 1. Assert: Type(isoString) is String.
|
||||
|
||||
@ -909,7 +909,7 @@ Optional<TemporalTime> parse_temporal_time_string(GlobalObject& global_object, [
|
||||
// TODO
|
||||
|
||||
// 3. Let result be ? ParseISODateTime(isoString).
|
||||
auto result = TRY_OR_DISCARD(parse_iso_date_time(global_object, iso_string));
|
||||
auto result = TRY(parse_iso_date_time(global_object, iso_string));
|
||||
|
||||
// 4. Return the Record { [[Hour]]: result.[[Hour]], [[Minute]]: result.[[Minute]], [[Second]]: result.[[Second]], [[Millisecond]]: result.[[Millisecond]], [[Microsecond]]: result.[[Microsecond]], [[Nanosecond]]: result.[[Nanosecond]], [[Calendar]]: result.[[Calendar]] }.
|
||||
return TemporalTime { .hour = result.hour, .minute = result.minute, .second = result.second, .millisecond = result.millisecond, .microsecond = result.microsecond, .nanosecond = result.nanosecond, .calendar = move(result.calendar) };
|
||||
|
@ -109,7 +109,7 @@ ThrowCompletionOr<String> parse_temporal_calendar_string(GlobalObject&, String c
|
||||
ThrowCompletionOr<TemporalDate> parse_temporal_date_string(GlobalObject&, String const& iso_string);
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(GlobalObject&, String const& iso_string);
|
||||
ThrowCompletionOr<TemporalDuration> parse_temporal_duration_string(GlobalObject&, String const& iso_string);
|
||||
Optional<TemporalTime> parse_temporal_time_string(GlobalObject&, String const& iso_string);
|
||||
ThrowCompletionOr<TemporalTime> parse_temporal_time_string(GlobalObject&, String const& iso_string);
|
||||
Optional<TemporalTimeZone> parse_temporal_time_zone_string(GlobalObject&, String const& iso_string);
|
||||
Optional<TemporalYearMonth> parse_temporal_year_month_string(GlobalObject&, String const& iso_string);
|
||||
double to_positive_integer(GlobalObject&, Value argument);
|
||||
|
@ -108,9 +108,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(GlobalObject& global_object, Valu
|
||||
return throw_completion(exception->value());
|
||||
|
||||
// b. Let result be ? ParseTemporalTimeString(string).
|
||||
result = parse_temporal_time_string(global_object, string);
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
result = TRY(parse_temporal_time_string(global_object, string));
|
||||
|
||||
// c. Assert: ! IsValidTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]) is true.
|
||||
VERIFY(is_valid_time(result->hour, result->minute, result->second, result->millisecond, result->microsecond, result->nanosecond));
|
||||
|
Loading…
Reference in New Issue
Block a user