diff --git a/Userland/Libraries/LibTimeZone/TimeZone.cpp b/Userland/Libraries/LibTimeZone/TimeZone.cpp index b87f11fc3a..251f84c11c 100644 --- a/Userland/Libraries/LibTimeZone/TimeZone.cpp +++ b/Userland/Libraries/LibTimeZone/TimeZone.cpp @@ -5,6 +5,7 @@ */ #include +#include namespace TimeZone { @@ -19,6 +20,17 @@ enum class TimeZone : u16 { }; #endif +StringView current_time_zone() +{ + static bool initialized_time_zone = false; + if (!initialized_time_zone) { + initialized_time_zone = true; + tzset(); + } + + return tzname[0]; +} + Optional __attribute__((weak)) time_zone_from_string([[maybe_unused]] StringView time_zone) { #if !ENABLE_TIME_ZONE_DATA diff --git a/Userland/Libraries/LibTimeZone/TimeZone.h b/Userland/Libraries/LibTimeZone/TimeZone.h index 2fe55583a8..d7c5ef4c13 100644 --- a/Userland/Libraries/LibTimeZone/TimeZone.h +++ b/Userland/Libraries/LibTimeZone/TimeZone.h @@ -14,6 +14,8 @@ namespace TimeZone { +StringView current_time_zone(); + Optional time_zone_from_string(StringView time_zone); StringView time_zone_to_string(TimeZone time_zone); Optional canonicalize_time_zone(StringView time_zone);