From 0cfc921461ef3b6674c7f3cd786342419edc9d2a Mon Sep 17 00:00:00 2001 From: Adrian Scillato <35405447+ascillato@users.noreply.github.com> Date: Sun, 13 May 2018 00:12:02 -0300 Subject: [PATCH] Fix DST and STD times for Southern Hemisphere Fix issue #2684 DST and STD times for Southern Hemisphere --- sonoff/support.ino | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/sonoff/support.ino b/sonoff/support.ino index e56d7e540..84760e92b 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -1389,17 +1389,22 @@ void RtcSecond() if (local_time > 1451602800) { // 2016-01-01 int32_t time_offset = Settings.timezone * SECS_PER_HOUR; if (99 == Settings.timezone) { + dstoffset = DaylightSavingTime.offset * SECS_PER_MIN; + stdoffset = StandardTime.offset * SECS_PER_MIN; if (DaylightSavingTime.hemis) { - dstoffset = StandardTime.offset * SECS_PER_MIN; // Southern hemisphere - stdoffset = DaylightSavingTime.offset * SECS_PER_MIN; + // Southern hemisphere + if ((utc_time >= (standard_time - dstoffset)) && (utc_time < (daylight_saving_time - stdoffset))) { + time_offset = stdoffset; // Standard Time + } else { + time_offset = dstoffset; // Daylight Saving Time + } } else { - dstoffset = DaylightSavingTime.offset * SECS_PER_MIN; // Northern hemisphere - stdoffset = StandardTime.offset * SECS_PER_MIN; - } - if ((utc_time >= (daylight_saving_time - stdoffset)) && (utc_time < (standard_time - dstoffset))) { - time_offset = dstoffset; // Daylight Saving Time - } else { - time_offset = stdoffset; // Standard Time + // Northern hemisphere + if ((utc_time >= (daylight_saving_time - stdoffset)) && (utc_time < (standard_time - dstoffset))) { + time_offset = dstoffset; // Daylight Saving Time + } else { + time_offset = stdoffset; // Standard Time + } } } local_time += time_offset;