Browse Source

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 years ago
parent
commit
247caac7a8
1 changed files with 1 additions and 1 deletions
  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)