Skip to content

Commit daa906a

Browse files
committed
Fix time zones
1 parent 7308316 commit daa906a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Fade.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ uint16_t sunsetMaximumBrightness = 0;
1919
Ticker fadeTicker;
2020
Ticker hasBeenStartedResetTicker;
2121
bool hasBeenStarted = false;
22-
ConfigClass *config;
2322

2423
void initialize()
2524
{
26-
configTime(Config.timeZone * 3600, Config.summerTime * 3600, "pool.ntp.org", "time.nist.gov");
25+
configTime(0, 0, "pool.ntp.org", "time.nist.gov");
2726
getSunsetTime();
2827
}
2928

@@ -38,14 +37,15 @@ void handle()
3837
if (!n)
3938
return;
4039
struct tm *now = gmtime(&n);
40+
int8_t hour = (now->tm_hour + Config.timeZone + Config.summerTime) % 24;
4141

4242
// Check for alarm
43-
if (Config.alarmEnabled && now->tm_hour == Config.alarmHour && now->tm_min == Config.alarmMinute)
43+
if (Config.alarmEnabled && hour == Config.alarmHour && now->tm_min == Config.alarmMinute)
4444
{
4545
Fade::begin(Fade::FadeMode::ALARM);
4646
}
4747
// Check for sunset
48-
else if (Config.sunsetEnabled && now->tm_hour == Config.sunsetHour && now->tm_min == Config.sunsetMinute)
48+
else if (Config.sunsetEnabled && hour == Config.sunsetHour && now->tm_min == Config.sunsetMinute)
4949
{
5050
// Only start sunset if all leds are off
5151
if (FastLEDHub.brightness10 == 0)

0 commit comments

Comments
 (0)