Did you have a link to the Adafruit library if I find some time I will convert it. It's my fault I hadn't any use for the unixtime so i don't implement it sorry...
So the use of the compiletime is implemented, sort of this to use it:
rtc_clock.set_time(__TIME__);
rtc_clock.set_date(__DATE__);
re-used the code from Lady Ada, unixtime will be the next.
So unixtime implemented like the Adafruit library solved the problem:
rtc_clock.unixtime()
gives you the time in unixtime style.
Sample and Updated code will follow...
And now completed.
Sample for this:
#include <rtc_clock.h>
// Select the Slowclock source
//RTC_clock rtc_clock(RC);
RTC_clock rtc_clock(XTAL);
char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
void setup() {
Serial.begin(9600);
rtc_clock.init();
rtc_clock.set_time(__TIME__);
rtc_clock.set_date(__DATE__);
}
void loop() {
Serial.print("Unixtime: ");
Serial.println(rtc_clock.unixtime());
Serial.println("And in plain for everyone");
Serial.print("Time: ");
digitprint(rtc_clock.get_hours(), 2);
Serial.print(":");
digitprint(rtc_clock.get_minutes(), 2);
Serial.print(":");
digitprint(rtc_clock.get_seconds(), 2);
Serial.println("");
Serial.print("Date: ");
Serial.print(daynames[rtc_clock.get_day_of_week()-1]);
Serial.print(" ");
digitprint(rtc_clock.get_days(), 2);
Serial.print(".");
digitprint(rtc_clock.get_months(), 2);
Serial.print(".");
Serial.println(rtc_clock.get_years());
Serial.println("");
}
void digitprint(int value, int lenght){
for (int i = 0; i < (lenght - numdigits(value)); i++){
Serial.print("0");
}
Serial.print(value);
}
int numdigits(int i){
int digits;
if (i < 10)
digits = 1;
else
digits = (int)(log10((double)i)) + 1;
return digits;
}
New library is attached, tevroc would you like to test it.