- Tue May 23, 2017 2:06 am
#66209
I have solved the UTC, Local Standard Time and Daylight Savings time problem quite easily. I use the same process whether I get the time from a GPS or from NTP. I utilize the time.h (Time library) to help a bit. I get UTC seconds (since 1900), then get UNIX Epoch (since 1970). This is then current UTC. I adjust this to LocalStandardTime and never adjust that again. I have a separate Unsigned Long called DisplayTime that is adjusted, when appropriate, to DST. There is one line to adjust UTC to LocalStandardTime and one more line for adjusting to (the hated) Daylight Savings time.
The code for all of this is on my web site in a program which shows the time & date on a scrolling 8x8x8 LED display. One trick I use is to let the IsDST routine return a Boolean and multiply that by the DST offset. Makes the code simple. Find the code, including the IsDST routine at ILikeTheInternet.com. It was hosted on a Pi but the SD Card broke and I never got round to fixing it. I would like to host it on an ESP8266 but the library code is cryptic and I can't find the stuff I need to do it yet. So it is hosted on a different server here for now. One day I will reinstall the LAMP stack and run the server on one of the Pi's again or ESP8266.
I had a high function web server running on an Arduino but it was just too slow sending large pictures out so took it down. I was getting about 65KB with it. Poor for this juncture. But it worked quite well, otherwise. Still have that code. Wish it applied straight across to an ESP8266. But that would be way too easy, wouldn't it?!?!?! It all takes time...