For a while now I’ve had a mental itch that needed to be scratched and finally found some time to do something about it. I had a function called rtc_date_time_to_sec_since_y2k() to convert date&time to seconds since Y2K, but I did not have one in the reverse direction… until now 🙂
First I used an Excel Spreadsheet to have a broad overview of the algorithm:
Finally I created a test project for my RTC C module in the free (as in beer) Visual Studio Community Edition 2017. It tests the whole space (every second from 2000-01-01 00:00:00 to 2099-12-31 23:59:59) and took only 10 minutes on an Intel Core i7-6700 CPU @ 3.40GHz. Running the same test on an 8-bit Atmel AVR @ 7.37 MHz would take (a projected) 25 days!