diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-03-13 08:52:07 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-13 17:50:49 +0100 |
commit | 0dfb9714fe5a06bd7b532bdd35aa2d2852ea97d5 (patch) | |
tree | 4f677a92d9a73282f93976df7031000cde8417c7 /Userland/Libraries | |
parent | 7fceb909a525abe28e563c8024a20d76e6c4658d (diff) | |
download | serenity-0dfb9714fe5a06bd7b532bdd35aa2d2852ea97d5.zip |
LibCore: Use altzone for the current time zone offset during DST
Also use the daylight global to determine the current time zone name,
i.e. tzname[0] is standard time, tzname[1] is daylight savings time.
Note that altzone isn't required to be defined on all systems, so we
have to #ifdef to check if it exists in order for Lagom to build.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibCore/DateTime.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCore/DateTime.cpp b/Userland/Libraries/LibCore/DateTime.cpp index 525328d541..673eac810f 100644 --- a/Userland/Libraries/LibCore/DateTime.cpp +++ b/Userland/Libraries/LibCore/DateTime.cpp @@ -106,7 +106,9 @@ String DateTime::to_string(StringView format) const const int format_len = format.length(); auto format_time_zone_offset = [&](bool with_separator) { -#ifndef __FreeBSD__ +#if defined(__serenity__) + auto offset_seconds = daylight ? -altzone : -timezone; +#elif !defined(__FreeBSD__) auto offset_seconds = -timezone; #else auto offset_seconds = 0; @@ -251,7 +253,7 @@ String DateTime::to_string(StringView format) const format_time_zone_offset(true); break; case 'Z': - builder.append(tzname[0]); + builder.append(tzname[daylight]); break; case '%': builder.append('%'); |