Open smz opened 5 years ago
I am happy that it may be useful. Go ahead. You are welcome. Just go check the ongoing revision of the code I proposed (I posted a new version). Please go there and help testing it. And suggest improvements if you feel like it. I was thinking in proposing a ctime-based solution like the one you implemented in this repo, but I concluded that portability (for microcontrollers) is impaired when relying on time.h. In fact, for ESP8266 there is no mk_gmtime(), and the only way to create a time_t value is setting the TZ before using mktime(). Other useful functions are available for ESP8266 but not for AVR, like strptime().
Thank-you, @Martin-Laclaustra! Right now I'm Arduino-less (one is on-duty as my thermostat and another I borrowed it to a friend), but ASAP I'll add your function to my library.
Thanks also for the info about the ESP8266: as a matter of fact others have tried to use my library with it but it didn't work. I'll probably get one (it's an interesting piece of hardware...) and I'll try to make it compatible with it.
Writing this library (and the thermostat unit where it is used) has been my first attempt at programming/using microcontrollers, so my experience with them is limited...
Although this library essentially uses "Unix Time" there are methods to set the date based on the Gregorian calendar, therefore it could be a good idea to check their formal validity.
Pinging @Martin-Laclaustra: do you have any issue if I'm going to use the code you proposed for Makuna-Rtc? Of course I will be glad to recognize your contribution. Thanks in advance.