mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 23:57:25 +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:
committed by
Andreas Kling
parent
1af466babf
commit
f7efbba32d
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user