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.
pull/71/head
John Slemmer 6 years ago
parent ca056c175e
commit 2aaf8eb452

@ -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 = "???"; if (tzname == "UTC" && std_offset) tzname = "???";
is_dst = false; is_dst = false;
offset = std_offset; offset = std_offset;
return t - std_offset * 60; } else {
}
int16_t dst_offset = std_offset - dst_shift_hr * 60 - dst_shift_min; int16_t dst_offset = std_offset - dst_shift_hr * 60 - dst_shift_min;
// to find the year // to find the year
tmElements_t tm; tmElements_t tm;
@ -778,6 +776,7 @@ time_t Timezone::tzTime(time_t t, ezLocalOrUTC_t local_or_utc, String &tzname, b
} else { } else {
offset = std_offset; offset = std_offset;
} }
}
if (local_or_utc == LOCAL_TIME) { if (local_or_utc == LOCAL_TIME) {
return t + offset * 60LL; return t + offset * 60LL;

Loading…
Cancel
Save