I was a little surprised not to get any response for a library that gives date and time functionality to an arduino without the use of a real time clock. It was mentioned in this thread http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210889307#8 as a way of bypassing the millis rollover problem for sketches that need a way of manipulating and/or displaying times in units of seconds or more.
I was wondering if the cost and effort of integrating a separate real time clock is really no barrier to people that want this kind of functionality so no point in a 'Software Real Time Clock'.
Here are the advantages and disadvantages as I see them of both approaches, I would appreciate hearing your view on the relative merits of a software only solution.
The main advantages of software only solution is that there is no hardware to buy or integrate, everything runs on the Arduino. The main advantage of an external clock board is that it will keep the correct time even if the Arduino resets (the arduino soft solution needs to be synchronized, typically via a time message on the serial port.)
Here is the functionality in the DateTime library that I am using on the arduino. It is built on the standard time_t (an unsigned long) that is the number of seconds since midnight Jan 1 1970 (aka unix time).
void sync(time_t time); // set the internal clock to the given time
time_t now(); // return the current time as seconds since midnight Jan 1 1970
boolean available(); // refreshes the Date and Time properties and returns true if clock synced
// date and time properties updated using the timer0 overflow interrupt
byte Hour;
byte Minute;
byte Second;
byte Day;
byte DayofWeek; // Sunday is day 0
byte Month; // Jan is month 0
byte Year; // the Year minus 1900
// optional utility functions to convert to and from time components (hrs, secs, days, years etc) to time_t
// extracts time components from time_t
void localTime(time_t *timep,byte *psec,byte *pmin,byte *phour,byte *pday,byte *pwday,byte *pmonth,byte *pyear);
// returns time_t from components
time_t makeTime(uint8_t sec, uint8_t min, uint8_t hour, uint8_t day, uint8_t month, int year );
It takes more time to properly document something like this then it does to code it so I would like to hear views on the usefulness or otherwise of this before embarking on writing an article for the playground and posting the code there.