From e362b3b6aa524441c1ab963c4a470a207e83f922 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Fri, 1 Apr 2022 02:07:50 +0200 Subject: [PATCH] Fixed sunset time off by an hour on DST change day (fixes #2603) --- wled00/ntp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wled00/ntp.cpp b/wled00/ntp.cpp index b01584f7c..c30c62daf 100644 --- a/wled00/ntp.cpp +++ b/wled00/ntp.cpp @@ -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);