From 2aaf8eb45245d66fca5674df280dc9f78c4efb8a Mon Sep 17 00:00:00 2001 From: John Slemmer Date: Thu, 28 Nov 2019 09:05:03 -0800 Subject: [PATCH] fix bug where timezones not observing DST were incorrectly translated Timezones like Pacific/Honolulu and America/Phoenix (and probably others) do not observe DST. They always stay on their standard time. The previous code essentially treated all calls to `tzTime` in this time zone like the timestamp `t` was a UTC timestamp (subtracting the the offset). However, this is incorrect and should be able to translate both ways depending on what `local_or_utc` is set to. --- src/ezTime.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ezTime.cpp b/src/ezTime.cpp index 2a9f9b3..807123e 100644 --- a/src/ezTime.cpp +++ b/src/ezTime.cpp @@ -749,9 +749,7 @@ time_t Timezone::tzTime(time_t t, ezLocalOrUTC_t local_or_utc, String &tzname, b if (tzname == "UTC" && std_offset) tzname = "???"; is_dst = false; offset = std_offset; - return t - std_offset * 60; - } - + } else { int16_t dst_offset = std_offset - dst_shift_hr * 60 - dst_shift_min; // to find the year tmElements_t tm; @@ -778,6 +776,7 @@ time_t Timezone::tzTime(time_t t, ezLocalOrUTC_t local_or_utc, String &tzname, b } else { offset = std_offset; } + } if (local_or_utc == LOCAL_TIME) { return t + offset * 60LL;