mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02:00
LibJS: Implement parsing of TemporalDateTimeString
This commit is contained in:
Notes:
sideshowbarker
2024-07-18 00:56:34 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/b42b7d5f16e Pull-request: https://github.com/SerenityOS/serenity/pull/10971 Reviewed-by: https://github.com/IdanHo ✅ Reviewed-by: https://github.com/alimpfard
@@ -1261,16 +1261,21 @@ ThrowCompletionOr<TemporalDate> parse_temporal_date_string(GlobalObject& global_
|
||||
}
|
||||
|
||||
// 13.39 ParseTemporalDateTimeString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldatetimestring
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(GlobalObject& global_object, [[maybe_unused]] String const& iso_string)
|
||||
ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(GlobalObject& global_object, String const& iso_string)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. Assert: Type(isoString) is String.
|
||||
|
||||
// 2. If isoString does not satisfy the syntax of a TemporalDateTimeString (see 13.33), then
|
||||
// a. Throw a RangeError exception.
|
||||
// TODO
|
||||
auto parse_result = parse_iso8601(Production::TemporalDateTimeString, iso_string);
|
||||
if (!parse_result.has_value()) {
|
||||
// a. Throw a RangeError exception.
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDateTimeString, iso_string);
|
||||
}
|
||||
|
||||
// 3. Let result be ? ParseISODateTime(isoString).
|
||||
auto result = TRY(parse_iso_date_time(global_object, {}));
|
||||
auto result = TRY(parse_iso_date_time(global_object, *parse_result));
|
||||
|
||||
// 4. Return result.
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user