Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Time.h>
- #include <string.h>
- void readBuildDate(tmElements_t * tm){
- char *token = strtok(__DATE__, " ");
- static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
- tm->Month = (strstr(month_names, token)-month_names)/3+1;
- token = strtok(NULL, " ");
- tm->Day = atoi(token);
- token = strtok(NULL, " ");
- tm->Year = CalendarYrToTm(atoi(token));
- token = strtok(__TIME__, ":");
- tm->Hour = atoi(token);
- token = strtok(NULL, ":");
- tm->Minute = atoi(token);
- token = strtok(NULL, ":");
- tm->Second = atoi(token);
- }
- void setup(){
- // USAGE:
- tmElements_t btm;
- readBuildDate(&btm);
- }
Advertisement
Add Comment
Please, Sign In to add comment