/* put this stuff in your function */
struct tm build_tm;
time_t build_t;
if (strptime(__DATE__, "%b %d %Y", &build_tm) == NULL)
return(); /* error! */
if (strptime(__TIME__, "%H:%M:%S", &build_tm) == NULL)
return(); /* error! */
build_t = strptime(&build_tm);
if (build_t == -1)
return(); /* error! */
return(build_t);
There you go. Current epoch time is even easier:
#include <stdio.h>
time_t sec;
sec = time (NULL);
Assuming the user doesn't reset their system time just to run your program, you could use those two variables - build date and current date - to make decisions based on the age of the program.
- nzvyyx
No comments:
Post a Comment