Skip to content

Commit

Permalink
Fix DST and STD times for Southern Hemisphere
Browse files Browse the repository at this point in the history
Fix issue arendst#2684 DST and STD times for Southern Hemisphere
  • Loading branch information
ascillato authored May 13, 2018
1 parent e6a1eff commit 0cfc921
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions sonoff/support.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
} 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
// 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 {
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;
Expand Down

0 comments on commit 0cfc921

Please sign in to comment.