I am back on my simple date logging project, completely confused, I have looked at many libraries like Yet-Another DS1337 RTC library, and many of them look like I could do the simple task I require, but one uses unix , another based on year 2000, and I can't quite get it working. I have rethought the basic idea, after failing to get the upper and lower bytes of unix days stored and read back from the 1307 RTC ram. The new idea would work out much better than what I was trying, so I have scrapped the old sketch. I have three LED displays,
1 shows the number of days since the last event ( 2 digits 0-99)
2 shows the previous best ( longest) number of days since the last event ( 2 digits 0-99 )
3 shows the day, month, and year of the last event 2-2-2 digits.
The data for each is stored in the DS1307 ram in case power goes off I have a loop checking the date every minute, and if the day has changed, it recalculates the elapsed days, and refreshes the ram. I have buttons on a remote to set the displayed previous days month and year ( as well as to set the previous best display, and one to register an event ) If an event is registered, I calculate the larger of the "elapsed" and "previous best" days which becomes " previous best", "elapsed" is set to zero, and the current date becomes the previous date displayed.
What I want to try, is have the "elapsed days display" calculated on the fly ( in each loop ) from the difference between the current date and the previous date, with each press of the set date buttons - i.e. each loop.
I will need to store the previous date in the ram, ( which is where I had all the trouble using unix divided into days as a longint split into highByte and Low byte ) so if I can just store it as 3 integers :- "prevday" "prevmonth" "prevyear"
I need to be able to subtract current "day" "month" "year" from the RTC readDate ( or whichever library I use ) from the "prevday" "prevmonth" "prevyear" .
Can anyone point me to a library ( or simple instructions in Time.h ) or an example ,whereby I can convert any given YYMMDD to unix (or eclipse? or whatever) and back again after doing the subtraction?