From 8a27180fb8c4e838a402f4db50c5f858b0d77434 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 21 Mar 2023 11:16:26 -0400 Subject: [PATCH] LibCore: Set tm_isdst to a negative value before invoking mktime If it is default-initialized to 0, mktime will assume that DST is not in effect for the specified time. Setting it to a negative value instructs mktime to determine for itself whether DST is in effect. --- Userland/Libraries/LibCore/DateTime.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibCore/DateTime.cpp b/Userland/Libraries/LibCore/DateTime.cpp index add6fca290..1d32cdc426 100644 --- a/Userland/Libraries/LibCore/DateTime.cpp +++ b/Userland/Libraries/LibCore/DateTime.cpp @@ -280,7 +280,9 @@ Optional DateTime::parse(StringView format, DeprecatedString const& st { unsigned format_pos = 0; unsigned string_pos = 0; + struct tm tm = {}; + tm.tm_isdst = -1; auto parsing_failed = false; auto tm_represents_utc_time = false; @@ -549,4 +551,5 @@ Optional DateTime::parse(StringView format, DeprecatedString const& st return DateTime::from_timestamp(mktime(&tm)); } + }