mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
LibTimeZone: Add methods to canonicalize a time zone name
This commit is contained in:
parent
1c2c98ac5d
commit
e9c42d0bc5
3 changed files with 29 additions and 0 deletions
|
@ -11,4 +11,17 @@ namespace TimeZone {
|
|||
Optional<TimeZone> __attribute__((weak)) time_zone_from_string(StringView) { return {}; }
|
||||
StringView __attribute__((weak)) time_zone_to_string(TimeZone) { return {}; }
|
||||
|
||||
Optional<StringView> canonicalize_time_zone(StringView time_zone)
|
||||
{
|
||||
auto maybe_time_zone = time_zone_from_string(time_zone);
|
||||
if (!maybe_time_zone.has_value())
|
||||
return {};
|
||||
|
||||
auto canonical_time_zone = time_zone_to_string(*maybe_time_zone);
|
||||
if (canonical_time_zone.is_one_of("Etc/UTC"sv, "Etc/GMT"sv))
|
||||
return "UTC"sv;
|
||||
|
||||
return canonical_time_zone;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue