Closed gonzabrusco closed 1 year ago
The only solution I found for now is to take out of the class the boolean "overflow" and make it a global with the modifier RTC_DATA_ATTR to store it on the RTC memory.
Or having the entire class live inside the RTC memory (less optimal).
Ok I found a way of not having even to use the overflow flag. I think you'll love this. The gregorian calendar repeats every 28 years. So you can substract exactly 883612800 and you will read from the RTC the exact same dates except for the year. So you just need to substract this on setTime. When reading the RTC you will have to add only 28 years to the year. Everything else will remain the same!
So that way, you posponed 28 years more the Y2K38 problem. But without the problem of having to remember if you had an overflow or not!
The flag that marks the overflow (to avoid the Y2K38 problem) does not survive Deep Sleep making it not very useful. For example if you set the time above 2045 and then go to deep sleep, when you wake up you are back at 1979 (Back to The Future soundtrack enters here haha).