From b15a78f0d1e6a241b76063c9012c270913d8ebcc Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 8 Mar 2015 21:28:02 -0700 Subject: [PATCH] fix dst bug. --- Network.ino | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Network.ino b/Network.ino index 10f8d81..d7ce04b 100644 --- a/Network.ino +++ b/Network.ino @@ -386,13 +386,19 @@ void initClock() { if (ntptime>0) { setTime(ntptime); #ifdef AUTODST + logMessage(F("AutoDST enabled.")); if (IsDST(ntptime)) { + logMessage(F("It is currently DST.")); //dstoffset = STDTZOFFSET+1L; //dst isDst = true; ntptime += SECS_PER_HOUR; setTime(ntptime); //adjust to dst + } else { + logMessage(F("It is currently not DST.")); } + #else + logMessage(F("AutoDST disabled.")); #endif logMessage(F("Got NTP time ")); p(F("NTP sync OK. ")); @@ -476,7 +482,8 @@ boolean IsDST(time_t t) te.Second = 0; time_t dstStart,dstEnd; dstStart = makeTime(te); - dstStart = nextSunday(dstStart); + if (dayOfWeek(dstStart)!=dowSunday)//if Mar 1 is already a Sunday, skip one call to nextSunday + dstStart = nextSunday(dstStart); dstStart = nextSunday(dstStart); //second sunday in march dstStart += 2*SECS_PER_HOUR; te.Month=11;