mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibJS: Implement several more ISO8601 productions
This started with implementing TemporalMonthDayString. It turns out that the facilities needed to parse that production includes nearly all the helpers to parse each of: TemporalDateTimeString TemporalInstantString TemporalMonthDayString TemporalTimeString TemporalYearMonthString TemporalZonedDateTimeString As most of these invoke the same helpers with different options. So, all 6 of those productions are implemented here.
This commit is contained in:
parent
001df24935
commit
8af2f3ab2a
2 changed files with 987 additions and 62 deletions
File diff suppressed because it is too large
Load diff
|
@ -9,11 +9,42 @@
|
|||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
|
||||
struct Annotation {
|
||||
bool critical { false };
|
||||
StringView key;
|
||||
StringView value;
|
||||
};
|
||||
|
||||
struct TimeZoneOffset {
|
||||
Optional<char> sign;
|
||||
Optional<StringView> hours;
|
||||
Optional<StringView> minutes;
|
||||
Optional<StringView> seconds;
|
||||
Optional<StringView> fraction;
|
||||
StringView source_text;
|
||||
};
|
||||
|
||||
struct ParseResult {
|
||||
Optional<char> sign;
|
||||
|
||||
Optional<StringView> date_year;
|
||||
Optional<StringView> date_month;
|
||||
Optional<StringView> date_day;
|
||||
Optional<StringView> time_hour;
|
||||
Optional<StringView> time_minute;
|
||||
Optional<StringView> time_second;
|
||||
Optional<StringView> time_fraction;
|
||||
Optional<TimeZoneOffset> date_time_offset;
|
||||
|
||||
Optional<StringView> utc_designator;
|
||||
Optional<StringView> time_zone_identifier;
|
||||
Optional<StringView> time_zone_iana_name;
|
||||
Optional<TimeZoneOffset> time_zone_offset;
|
||||
|
||||
Optional<StringView> duration_years;
|
||||
Optional<StringView> duration_months;
|
||||
Optional<StringView> duration_weeks;
|
||||
|
@ -24,12 +55,30 @@ struct ParseResult {
|
|||
Optional<StringView> duration_minutes_fraction;
|
||||
Optional<StringView> duration_seconds;
|
||||
Optional<StringView> duration_seconds_fraction;
|
||||
|
||||
Vector<Annotation> annotations;
|
||||
};
|
||||
|
||||
enum class Production {
|
||||
AnnotationValue,
|
||||
DateMonth,
|
||||
TemporalDateTimeString,
|
||||
TemporalDurationString,
|
||||
TemporalInstantString,
|
||||
TemporalMonthDayString,
|
||||
TemporalTimeString,
|
||||
TemporalYearMonthString,
|
||||
TemporalZonedDateTimeString,
|
||||
TimeZoneIdentifier,
|
||||
};
|
||||
|
||||
Optional<ParseResult> parse_iso8601(Production, StringView);
|
||||
|
||||
enum class SubMinutePrecision {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
|
||||
Optional<TimeZoneOffset> parse_utc_offset(StringView, SubMinutePrecision);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue