mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
LibJS: Start fleshing out an ISO 8601 parser for Temporal
This is the start of a parser for the ISO 8601 grammar used in the Temporal spec: https://tc39.es/proposal-temporal/#sec-temporal-iso8601grammar We will, on purpose, not use a generic ISO 8601 parser from AK or similar for two reasons: - Many AOs make specific assumptions about which productions exist and access them directly, even when they're part of a larger production. - The spec says "The grammar deviates from the standard given in ISO 8601 in the following ways:" and then lists 17 of such deviations. Making that work with a general purpose parser is not worth it. The public API is not being used anywhere yet, but will be in the next couple of commits. Likewise, the Production enum will be populated with all the productions accessed directly (e.g. TemporalDateString). Many thanks to Ali for showing me how to improve my initial approach full of macros with a nice RAII helper - it's much nicer :^) Co-Authored-By: Ali Mohammad Pur <mpfard@serenityos.org>
This commit is contained in:
parent
dd76ba2fe1
commit
de23f0b68c
5 changed files with 634 additions and 26 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Temporal/ISO8601.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
|
||||
|
@ -126,7 +127,7 @@ double sign(double);
|
|||
double constrain_to_range(double x, double minimum, double maximum);
|
||||
i64 round_number_to_increment(double, u64 increment, StringView rounding_mode);
|
||||
BigInt* round_number_to_increment(GlobalObject&, BigInt const&, u64 increment, StringView rounding_mode);
|
||||
ThrowCompletionOr<ISODateTime> parse_iso_date_time(GlobalObject&, String const& iso_string);
|
||||
ThrowCompletionOr<ISODateTime> parse_iso_date_time(GlobalObject&, ParseResult const& parse_result);
|
||||
ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(GlobalObject&, String const& iso_string);
|
||||
ThrowCompletionOr<TemporalZonedDateTime> parse_temporal_zoned_date_time_string(GlobalObject&, String const& iso_string);
|
||||
ThrowCompletionOr<String> parse_temporal_calendar_string(GlobalObject&, String const& iso_string);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue