Pārlūkot izejas kodu

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.
Timothy Flynn 2 gadi atpakaļ
vecāks
revīzija
8a27180fb8
1 mainītis faili ar 3 papildinājumiem un 0 dzēšanām
  1. 3 0
      Userland/Libraries/LibCore/DateTime.cpp

+ 3 - 0
Userland/Libraries/LibCore/DateTime.cpp

@@ -280,7 +280,9 @@ Optional<DateTime> DateTime::parse(StringView format, DeprecatedString const& st
 {
 {
     unsigned format_pos = 0;
     unsigned format_pos = 0;
     unsigned string_pos = 0;
     unsigned string_pos = 0;
+
     struct tm tm = {};
     struct tm tm = {};
+    tm.tm_isdst = -1;
 
 
     auto parsing_failed = false;
     auto parsing_failed = false;
     auto tm_represents_utc_time = false;
     auto tm_represents_utc_time = false;
@@ -549,4 +551,5 @@ Optional<DateTime> DateTime::parse(StringView format, DeprecatedString const& st
 
 
     return DateTime::from_timestamp(mktime(&tm));
     return DateTime::from_timestamp(mktime(&tm));
 }
 }
+
 }
 }