From 62d8d1fdfda8d98c81a3635af391885424fa69e6 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 6 Jan 2022 10:23:57 -0500 Subject: [PATCH] LibUnicode: Move UTC verification to the scope that requires it In Unicode::get_time_zone_name(), we don't need to require that the time zone is UTC for long- and short-style name lookups. This is required for other styles, because they will depend on TZDB data - so move the VERIFY to that scope. --- .../LibUnicode/GenerateUnicodeDateTimeFormat.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp index 2b882db72da..e2d22afcbd3 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp @@ -2098,12 +2098,6 @@ static TimeZoneData const* find_time_zone_data(StringView locale, StringView tim Optional get_time_zone_name(StringView locale, StringView time_zone, CalendarPatternStyle style) { - // FIXME: This becomes more complicated when time zones other than UTC are supported. We will need to know the GMT offset - // of each time zone (which must be parsed from the time zone database, not the CLDR). For now, assuming UTC means - // we can assume a GMT offset of 0, for which the CLDR has a specific format string for the offset styles. Further, - // we will need to parse the "generic" time zone names from timeZoneNames.json. - VERIFY(time_zone == "UTC"sv); - if ((style == CalendarPatternStyle::Long) || (style == CalendarPatternStyle::Short)) { if (auto const* data = find_time_zone_data(locale, time_zone); data != nullptr) { auto time_zone_index = style == CalendarPatternStyle::Long ? data->long_name : data->short_name; @@ -2111,6 +2105,12 @@ Optional get_time_zone_name(StringView locale, StringView time_zone, return s_string_list[time_zone_index]; } } else { + // FIXME: This becomes more complicated when time zones other than UTC are supported. We will need to know the GMT offset + // of each time zone (which must be parsed from the time zone database, not the CLDR). For now, assuming UTC means + // we can assume a GMT offset of 0, for which the CLDR has a specific format string for the offset styles. Further, + // we will need to parse the "generic" time zone names from timeZoneNames.json. + VERIFY(time_zone == "UTC"sv); + if (auto const* formats = find_time_zone_formats(locale); formats != nullptr) return s_string_list[formats->gmt_zero_format]; }