1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

LibTimeZone: Extract and parse the backwards compatibility LINK entries

This set of LINK entries contains the link from "UTC" to "Etc/UTC",
which LibJS will heavily depend upon.
This commit is contained in:
Timothy Flynn 2022-01-07 09:05:35 -05:00 committed by Linus Groh
parent b5758a0623
commit 87abf00f7c
2 changed files with 14 additions and 8 deletions

View file

@ -168,15 +168,17 @@ static ErrorOr<void> parse_time_zones(StringView time_zone_path, TimeZoneData& t
static String format_identifier(StringView owner, String identifier)
{
constexpr auto gmt_time_zone = "Etc/GMT"sv;
constexpr auto gmt_time_zones = Array { "Etc/GMT"sv, "GMT"sv };
if (identifier.starts_with(gmt_time_zone)) {
auto offset = identifier.substring_view(gmt_time_zone.length());
for (auto gmt_time_zone : gmt_time_zones) {
if (identifier.starts_with(gmt_time_zone)) {
auto offset = identifier.substring_view(gmt_time_zone.length());
if (offset.starts_with('+'))
identifier = String::formatted("{}_P{}", gmt_time_zone, offset.substring_view(1));
else if (offset.starts_with('-'))
identifier = String::formatted("{}_M{}", gmt_time_zone, offset.substring_view(1));
if (offset.starts_with('+'))
identifier = String::formatted("{}_P{}", gmt_time_zone, offset.substring_view(1));
else if (offset.starts_with('-'))
identifier = String::formatted("{}_M{}", gmt_time_zone, offset.substring_view(1));
}
}
identifier = identifier.replace("-"sv, "_"sv, true);