mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
LibJS: Add optional calendar to Plain{Time,YearMonth,MonthDay} prod
This is a normative change in the Temporal spec.
See: 7e58ba3
This commit is contained in:
parent
b70a55bd5a
commit
6d5e95d621
2 changed files with 25 additions and 24 deletions
|
@ -782,17 +782,6 @@ bool ISO8601Parser::parse_time_spec()
|
||||||
return true;
|
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
|
// https://tc39.es/proposal-temporal/#prod-TimeSpecSeparator
|
||||||
bool ISO8601Parser::parse_time_spec_separator()
|
bool ISO8601Parser::parse_time_spec_separator()
|
||||||
{
|
{
|
||||||
|
@ -819,6 +808,18 @@ bool ISO8601Parser::parse_date_time()
|
||||||
return true;
|
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
|
// https://tc39.es/proposal-temporal/#prod-CalendarDateTime
|
||||||
bool ISO8601Parser::parse_calendar_date_time()
|
bool ISO8601Parser::parse_calendar_date_time()
|
||||||
{
|
{
|
||||||
|
@ -1173,10 +1174,10 @@ bool ISO8601Parser::parse_temporal_month_day_string()
|
||||||
{
|
{
|
||||||
// TemporalMonthDayString :
|
// TemporalMonthDayString :
|
||||||
// DateSpecMonthDay
|
// DateSpecMonthDay
|
||||||
// DateTime
|
// CalendarDateTime
|
||||||
// NOTE: Reverse order here because `DateSpecMonthDay` can be a subset of `DateTime`,
|
// 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.
|
// 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();
|
|| parse_date_spec_month_day();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1184,12 +1185,12 @@ bool ISO8601Parser::parse_temporal_month_day_string()
|
||||||
bool ISO8601Parser::parse_temporal_time_string()
|
bool ISO8601Parser::parse_temporal_time_string()
|
||||||
{
|
{
|
||||||
// TemporalTimeString :
|
// TemporalTimeString :
|
||||||
// Time
|
// CalendarTime
|
||||||
// DateTime
|
// CalendarDateTime
|
||||||
// NOTE: Reverse order here because `Time` can be a subset of `DateTime`,
|
// 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.
|
// 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_time();
|
|| parse_calendar_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://tc39.es/proposal-temporal/#prod-TemporalTimeZoneIdentifier
|
// https://tc39.es/proposal-temporal/#prod-TemporalTimeZoneIdentifier
|
||||||
|
@ -1226,10 +1227,10 @@ bool ISO8601Parser::parse_temporal_year_month_string()
|
||||||
{
|
{
|
||||||
// TemporalYearMonthString :
|
// TemporalYearMonthString :
|
||||||
// DateSpecYearMonth
|
// DateSpecYearMonth
|
||||||
// DateTime
|
// CalendarDateTime
|
||||||
// NOTE: Reverse order here because `DateSpecYearMonth` can be a subset of `DateTime`,
|
// 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.
|
// 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();
|
|| parse_date_spec_year_month();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1256,7 +1257,7 @@ bool ISO8601Parser::parse_temporal_calendar_string()
|
||||||
// CalendarName
|
// CalendarName
|
||||||
// TemporalInstantString
|
// TemporalInstantString
|
||||||
// CalendarDateTime
|
// CalendarDateTime
|
||||||
// Time
|
// CalendarTime
|
||||||
// DateSpecYearMonth
|
// DateSpecYearMonth
|
||||||
// DateSpecMonthDay
|
// DateSpecMonthDay
|
||||||
return parse_calendar_name()
|
return parse_calendar_name()
|
||||||
|
@ -1264,7 +1265,7 @@ bool ISO8601Parser::parse_temporal_calendar_string()
|
||||||
|| parse_calendar_date_time()
|
|| parse_calendar_date_time()
|
||||||
|| parse_date_spec_year_month()
|
|| parse_date_spec_year_month()
|
||||||
|| parse_date_spec_month_day()
|
|| parse_date_spec_month_day()
|
||||||
|| parse_time();
|
|| parse_calendar_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://tc39.es/proposal-temporal/#prod-TemporalRelativeToString
|
// https://tc39.es/proposal-temporal/#prod-TemporalRelativeToString
|
||||||
|
|
|
@ -124,9 +124,9 @@ public:
|
||||||
[[nodiscard]] bool parse_calendar_name();
|
[[nodiscard]] bool parse_calendar_name();
|
||||||
[[nodiscard]] bool parse_calendar();
|
[[nodiscard]] bool parse_calendar();
|
||||||
[[nodiscard]] bool parse_time_spec();
|
[[nodiscard]] bool parse_time_spec();
|
||||||
[[nodiscard]] bool parse_time();
|
|
||||||
[[nodiscard]] bool parse_time_spec_separator();
|
[[nodiscard]] bool parse_time_spec_separator();
|
||||||
[[nodiscard]] bool parse_date_time();
|
[[nodiscard]] bool parse_date_time();
|
||||||
|
[[nodiscard]] bool parse_calendar_time();
|
||||||
[[nodiscard]] bool parse_calendar_date_time();
|
[[nodiscard]] bool parse_calendar_date_time();
|
||||||
[[nodiscard]] bool parse_duration_whole_seconds();
|
[[nodiscard]] bool parse_duration_whole_seconds();
|
||||||
[[nodiscard]] bool parse_duration_seconds_fraction();
|
[[nodiscard]] bool parse_duration_seconds_fraction();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue