Skip to content

Commit

Permalink
Fixed sunset time off by an hour on DST change day (fixes wled#2603)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aircoookie committed Apr 1, 2022
1 parent d2ced93 commit e362b3b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions wled00/ntp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ void calculateSunriseAndSunset() {
int minUTC = getSunriseUTC(year(localTime), month(localTime), day(localTime), latitude, longitude);
if (minUTC) {
// there is a sunrise
if (minUTC < 0) minUTC += 24*60; // add a day if negative
tim_0.tm_hour = minUTC / 60;
tim_0.tm_min = minUTC % 60;
sunrise = tz->toLocal(mktime(&tim_0) + utcOffsetSecs);
Expand All @@ -477,6 +478,7 @@ void calculateSunriseAndSunset() {
minUTC = getSunriseUTC(year(localTime), month(localTime), day(localTime), latitude, longitude, true);
if (minUTC) {
// there is a sunset
if (minUTC < 0) minUTC += 24*60; // add a day if negative
tim_0.tm_hour = minUTC / 60;
tim_0.tm_min = minUTC % 60;
sunset = tz->toLocal(mktime(&tim_0) + utcOffsetSecs);
Expand Down

0 comments on commit e362b3b

Please sign in to comment.