A lightweight DateTime library specializing for AVR development as well as C.
#include "datetime.h"
#include <stdio.h>
#include <unistd.h>
#include "datetime.h"
int main() {
DateTime d;
setDateTime(&d, 2016, 1, 1, 0, 0, 0);
while(1) {
printf("%d/%d/%d\n%d:%d:%d\n",
d.year, d.month, d.day, d.hour, d.minute, d.second);
sleep(1);
tickSecond(&d);
}
return 0;
}
DateTime d;
: declare a new DateTime variableunsigned int d.year
: get the yearunsigned int d.month
: get the monthunsigned int d.day
: get the dayunsigned int d.hour
: get the hourunsigned int d.minute
: get the minuteunsigned int d.day
: get the dayvoid setDateTime(DateTime* d, int year, int month, int day, int hour, int minute, int second)
: set the time to the desired parametersvoid tickSecond(DateTime* d)
: tick 1 second and updat the variable