소스 검색

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.
Timothy Flynn 3 년 전
부모
커밋
62d8d1fdfd
1개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 6 6
      Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp

+ 6 - 6
Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp

@@ -2098,12 +2098,6 @@ static TimeZoneData const* find_time_zone_data(StringView locale, StringView tim
 
 Optional<StringView> 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<StringView> 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];
     }