Fixed sunset time off by an hour on DST change day (fixes #2603)

This commit is contained in:
cschwinne 2022-04-01 02:07:50 +02:00
parent d2ced93e58
commit e362b3b6aa

View File

@ -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);
@ -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);