jim121049 wrote:I've tweaked the SNTP example ( the second one) to automatically determine whether Daylight Saving Time is in effect (in the United States).Code: Select allif isDST(hr,dy,mo,yr) then hr=hr+1 end -- Daylight Saving Time is in effect, add one hour
return hr,mn,sc,mo,dy,yr
Guess you've never been up late at night seeing your watch display 24:03?

Like the Timezone offset, the DST offset must be added to the timestamp before hour, minute, day etc. is calculated...
RFZ wrote:jim121049 wrote:I've tweaked the SNTP example ( the second one) to automatically determine whether Daylight Saving Time is in effect (in the United States).Code: Select allif isDST(hr,dy,mo,yr) then hr=hr+1 end -- Daylight Saving Time is in effect, add one hour
return hr,mn,sc,mo,dy,yr
Guess you've never been up late at night seeing your watch display 24:03?
Like the Timezone offset, the DST offset must be added to the timestamp before hour, minute, day etc. is calculated...
You're right of course, as I've since observed. The problem with adding the DST offset to the timestamp before the hour, minute ,day, etc. is calculated is that you need to have the hour, minute, day, etc. to know whether DST is in effect. How about:
if isDST(hr,dy,mo,yr) then hr=(hr+1)%24 end -- Daylight Saving Time is in effect, add one hour
return hr,mn,sc,mo,dy,yr