diff options
author | Linus Groh <mail@linusgroh.de> | 2021-12-18 20:58:36 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-12-18 22:32:39 +0000 |
commit | 6da6da73ccc45a28f7b638f7cda67553c784e3a0 (patch) | |
tree | d456ff1770807471b8a79b65489267f0482307ef | |
parent | acce65b52c0ac560a3cc95b2cb8314143d0cad92 (diff) | |
download | serenity-6da6da73ccc45a28f7b638f7cda67553c784e3a0.zip |
LibJS: Allow 'T' prefix in time-only strings
This is a normative change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/f5e8edf
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp | 19 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp index 457b70cb24..446d34fed6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp @@ -201,10 +201,10 @@ bool ISO8601Parser::parse_date_time_separator() || m_state.lexer.consume_specific('t'); } -// https://tc39.es/proposal-temporal/#prod-DurationTimeDesignator -bool ISO8601Parser::parse_duration_time_designator() +// https://tc39.es/proposal-temporal/#prod-TimeDesignator +bool ISO8601Parser::parse_time_designator() { - // DurationTimeDesignator : one of + // TimeDesignator : one of // T t return m_state.lexer.consume_specific('T') || m_state.lexer.consume_specific('t'); @@ -812,11 +812,14 @@ bool ISO8601Parser::parse_date_time() bool ISO8601Parser::parse_calendar_time() { // CalendarTime : - // TimeSpec TimeZone[opt] Calendar[opt] + // TimeDesignator[opt] TimeSpec TimeZone[opt] Calendar[opt] + StateTransaction transaction { *this }; + (void)parse_time_designator(); if (!parse_time_spec()) return false; (void)parse_time_zone(); (void)parse_calendar(); + transaction.commit(); return true; } @@ -962,11 +965,11 @@ bool ISO8601Parser::parse_duration_hours_part() bool ISO8601Parser::parse_duration_time() { // DurationTime : - // DurationTimeDesignator DurationHoursPart - // DurationTimeDesignator DurationMinutesPart - // DurationTimeDesignator DurationSecondsPart + // TimeDesignator DurationHoursPart + // TimeDesignator DurationMinutesPart + // TimeDesignator DurationSecondsPart StateTransaction transaction { *this }; - if (!parse_duration_time_designator()) + if (!parse_time_designator()) return false; auto success = parse_duration_hours_part() || parse_duration_minutes_part() diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h b/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h index 0ccc5a0e7c..749e4ac34e 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h @@ -90,7 +90,7 @@ public: [[nodiscard]] bool parse_duration_designator(); [[nodiscard]] bool parse_seconds_designator(); [[nodiscard]] bool parse_date_time_separator(); - [[nodiscard]] bool parse_duration_time_designator(); + [[nodiscard]] bool parse_time_designator(); [[nodiscard]] bool parse_weeks_designator(); [[nodiscard]] bool parse_years_designator(); [[nodiscard]] bool parse_utc_designator(); |