瀏覽代碼

LibTimeZone: Canonicalize the current time zone and fall back to UTC

If the tzname is unknown, fall back to UTC for now. Unknown time zones
are most likely due to not parsing RULE entries yet, but at the very
least, it only makes sense for current_time_zone to return a time zone
that LibTimeZone actually knows about.
Timothy Flynn 3 年之前
父節點
當前提交
247caac7a8
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Userland/Libraries/LibTimeZone/TimeZone.cpp

+ 1 - 1
Userland/Libraries/LibTimeZone/TimeZone.cpp

@@ -28,7 +28,7 @@ StringView current_time_zone()
         tzset();
     }
 
-    return tzname[0];
+    return canonicalize_time_zone(tzname[0]).value_or("UTC"sv);
 }
 
 Optional<TimeZone> __attribute__((weak)) time_zone_from_string([[maybe_unused]] StringView time_zone)