Chat freely about anything...

User avatar
By proj964
#66398
Code: Select allvoid configTime(int timezone, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)


1 - why does this interface use timezone in seconds, rather than hours?
2 - s_daylightOffset_sec is set but never appears to be used. what is its purpose?

thanks, jon
User avatar
By sixbacon
#67291 Unix time and the time servers all work in seconds, from some base date 1/1/1900 or 1/1/1970. Thus, the arithmetic is all done in seconds. It is easier to use this as the base unit, rather than to try to keep in mind whether something is in hours or days or seconds, and just convert to the relevant unit at the end.

There are some places in the world where fractional time zones are used, 30 min and 45 min. If an integer hour constant was used, it would not be much use the people living in these places! Could use a real, but then you loose the precision of integer arithmetic.

As for DST or daylightOffset_sec not working, this is true for me and others see https://github.com/esp8266/Arduino/issues/2505. Given the great work done by the team supporting the ESP8266 in the Arduino IDE, I can live with this and will write a function to do the DST correction.

I hope this clarifies things.