Created
September 30, 2009 21:07
-
-
Save dbussink/198455 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
int main(void) | |
{ | |
time_t now; | |
struct tm *ts; | |
char buf[80]; | |
/* Some distant moment in the past */ | |
now = -10000000000; | |
/* Format and print the time, "ddd yyyy-mm-dd hh:mm:ss zzz" */ | |
ts = localtime(&now); | |
strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", ts); | |
printf("%s\n", buf); | |
/* Try to get the timestamp moment back */ | |
time_t now2 = mktime(ts); | |
printf("%i\n", now2); | |
return 0; | |
} | |
============= | |
Mon 1653-02-10 06:32:52 AMT | |
-1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment