1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

LibCore: Add parser for time offset without a sign

There is already a parser for the time offset but it requires a positive
or negative sign. There are some weird formats on the web that do not
have the sign, so let's support that. I chose to implement this as a new
option instead of editing the old one to avoid any unknown breaking
changes.
This commit is contained in:
Kyle Lanmon 2024-01-28 23:27:35 -06:00 committed by Andreas Kling
parent 1af466babf
commit f7efbba32d

View file

@ -515,6 +515,21 @@ Optional<DateTime> DateTime::parse(StringView format, StringView string)
tm.tm_min += sign * minutes;
break;
}
case 'x': {
tm_represents_utc_time = true;
auto hours = parse_number();
int minutes;
if (string_lexer.consume_specific(':')) {
minutes = parse_number();
} else {
minutes = hours % 100;
hours = hours / 100;
}
tm.tm_hour -= hours;
tm.tm_min -= minutes;
break;
}
case 'Z':
parsed_time_zone = parse_time_zone_name(string_lexer);
if (!parsed_time_zone.has_value())