From 247caac7a8ee421efe3aa33f37f43d027e2187f1 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 14 Jan 2022 13:07:19 -0500 Subject: [PATCH] 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. --- Userland/Libraries/LibTimeZone/TimeZone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibTimeZone/TimeZone.cpp b/Userland/Libraries/LibTimeZone/TimeZone.cpp index 251f84c11c..ba2d4eb154 100644 --- a/Userland/Libraries/LibTimeZone/TimeZone.cpp +++ b/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 __attribute__((weak)) time_zone_from_string([[maybe_unused]] StringView time_zone)