Skip to content

Commit

Permalink
fix dst bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
d0ughb0y committed Mar 9, 2015
1 parent 259312f commit b15a78f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Network.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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. "));
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b15a78f

Please sign in to comment.