浏览代码

LibJS: Set DateTimeFormat's time zone when the CLDR download is disabled

We return early from the DateTimeFormat constructor to avoid crashing on
assertions when the CLDR is disabled. However, after commit 019211b, the
spec now mandates we assert the time zone identifier is valid. The early
return resulted in this identifier being an empty string.
Timothy Flynn 2 年之前
父节点
当前提交
897c7f7cc2
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp

+ 3 - 1
Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp

@@ -169,8 +169,10 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
     auto default_hour_cycle = ::Locale::get_default_regional_hour_cycle(data_locale);
     auto default_hour_cycle = ::Locale::get_default_regional_hour_cycle(data_locale);
 
 
     // Non-standard, default_hour_cycle will be empty if Unicode data generation is disabled.
     // Non-standard, default_hour_cycle will be empty if Unicode data generation is disabled.
-    if (!default_hour_cycle.has_value())
+    if (!default_hour_cycle.has_value()) {
+        date_time_format.set_time_zone(default_time_zone());
         return &date_time_format;
         return &date_time_format;
+    }
 
 
     Optional<::Locale::HourCycle> hour_cycle_value;
     Optional<::Locale::HourCycle> hour_cycle_value;