mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +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:
parent
1af466babf
commit
f7efbba32d
1 changed files with 15 additions and 0 deletions
|
@ -515,6 +515,21 @@ Optional<DateTime> DateTime::parse(StringView format, StringView string)
|
||||||
tm.tm_min += sign * minutes;
|
tm.tm_min += sign * minutes;
|
||||||
break;
|
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':
|
case 'Z':
|
||||||
parsed_time_zone = parse_time_zone_name(string_lexer);
|
parsed_time_zone = parse_time_zone_name(string_lexer);
|
||||||
if (!parsed_time_zone.has_value())
|
if (!parsed_time_zone.has_value())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue