mbed workshop intro + cansat examples

RTC1.cpp

Committer:
yamaguch
Date:
2012-05-10
Revision:
0:f309f06aeec7

File content as of revision 0:f309f06aeec7:

#include "mbed.h"

int main() {
    time_t seconds;
    char buf[32];

    seconds = (((2011 - 1969) * 365 + (2011 - 1968) / 4)
               + 31 + 29 + 31 + 30 + 26) * 24 * 3600
              + 15 * 3600 + 14 * 60;
    set_time(seconds);
    seconds = time(NULL);
    strftime(buf, sizeof(buf), "%x %X", localtime(&seconds));
    printf("mbed rtc = %s (timestamp = %d)\n", buf, seconds);
}