mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
LibJS: Add optional calendar to Plain{Time,YearMonth,MonthDay} prod
This is a normative change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/7e58ba3
This commit is contained in:
parent
b70a55bd5a
commit
6d5e95d621
Notes:
sideshowbarker
2024-07-17 22:38:48 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/6d5e95d6216 Pull-request: https://github.com/SerenityOS/serenity/pull/11298 Reviewed-by: https://github.com/IdanHo ✅
@ -782,17 +782,6 @@ bool ISO8601Parser::parse_time_spec()
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-Time
|
||||
bool ISO8601Parser::parse_time()
|
||||
{
|
||||
// Time :
|
||||
// TimeSpec TimeZone[opt]
|
||||
if (!parse_time_spec())
|
||||
return false;
|
||||
(void)parse_time_zone();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeSpecSeparator
|
||||
bool ISO8601Parser::parse_time_spec_separator()
|
||||
{
|
||||
@ -819,6 +808,18 @@ bool ISO8601Parser::parse_date_time()
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-CalendarTime
|
||||
bool ISO8601Parser::parse_calendar_time()
|
||||
{
|
||||
// CalendarTime :
|
||||
// TimeSpec TimeZone[opt] Calendar[opt]
|
||||
if (!parse_time_spec())
|
||||
return false;
|
||||
(void)parse_time_zone();
|
||||
(void)parse_calendar();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-CalendarDateTime
|
||||
bool ISO8601Parser::parse_calendar_date_time()
|
||||
{
|
||||
@ -1173,10 +1174,10 @@ bool ISO8601Parser::parse_temporal_month_day_string()
|
||||
{
|
||||
// TemporalMonthDayString :
|
||||
// DateSpecMonthDay
|
||||
// DateTime
|
||||
// NOTE: Reverse order here because `DateSpecMonthDay` can be a subset of `DateTime`,
|
||||
// CalendarDateTime
|
||||
// NOTE: Reverse order here because `DateSpecMonthDay` can be a subset of `CalendarDateTime`,
|
||||
// so we'd not attempt to parse that but may not exhaust the input string.
|
||||
return parse_date_time()
|
||||
return parse_calendar_date_time()
|
||||
|| parse_date_spec_month_day();
|
||||
}
|
||||
|
||||
@ -1184,12 +1185,12 @@ bool ISO8601Parser::parse_temporal_month_day_string()
|
||||
bool ISO8601Parser::parse_temporal_time_string()
|
||||
{
|
||||
// TemporalTimeString :
|
||||
// Time
|
||||
// DateTime
|
||||
// CalendarTime
|
||||
// CalendarDateTime
|
||||
// NOTE: Reverse order here because `Time` can be a subset of `DateTime`,
|
||||
// so we'd not attempt to parse that but may not exhaust the input string.
|
||||
return parse_date_time()
|
||||
|| parse_time();
|
||||
return parse_calendar_date_time()
|
||||
|| parse_calendar_time();
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TemporalTimeZoneIdentifier
|
||||
@ -1226,10 +1227,10 @@ bool ISO8601Parser::parse_temporal_year_month_string()
|
||||
{
|
||||
// TemporalYearMonthString :
|
||||
// DateSpecYearMonth
|
||||
// DateTime
|
||||
// NOTE: Reverse order here because `DateSpecYearMonth` can be a subset of `DateTime`,
|
||||
// CalendarDateTime
|
||||
// NOTE: Reverse order here because `DateSpecYearMonth` can be a subset of `CalendarDateTime`,
|
||||
// so we'd not attempt to parse that but may not exhaust the input string.
|
||||
return parse_date_time()
|
||||
return parse_calendar_date_time()
|
||||
|| parse_date_spec_year_month();
|
||||
}
|
||||
|
||||
@ -1256,7 +1257,7 @@ bool ISO8601Parser::parse_temporal_calendar_string()
|
||||
// CalendarName
|
||||
// TemporalInstantString
|
||||
// CalendarDateTime
|
||||
// Time
|
||||
// CalendarTime
|
||||
// DateSpecYearMonth
|
||||
// DateSpecMonthDay
|
||||
return parse_calendar_name()
|
||||
@ -1264,7 +1265,7 @@ bool ISO8601Parser::parse_temporal_calendar_string()
|
||||
|| parse_calendar_date_time()
|
||||
|| parse_date_spec_year_month()
|
||||
|| parse_date_spec_month_day()
|
||||
|| parse_time();
|
||||
|| parse_calendar_time();
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TemporalRelativeToString
|
||||
|
@ -124,9 +124,9 @@ public:
|
||||
[[nodiscard]] bool parse_calendar_name();
|
||||
[[nodiscard]] bool parse_calendar();
|
||||
[[nodiscard]] bool parse_time_spec();
|
||||
[[nodiscard]] bool parse_time();
|
||||
[[nodiscard]] bool parse_time_spec_separator();
|
||||
[[nodiscard]] bool parse_date_time();
|
||||
[[nodiscard]] bool parse_calendar_time();
|
||||
[[nodiscard]] bool parse_calendar_date_time();
|
||||
[[nodiscard]] bool parse_duration_whole_seconds();
|
||||
[[nodiscard]] bool parse_duration_seconds_fraction();
|
||||
|
Loading…
Reference in New Issue
Block a user