dbussink (owner)

Revisions

gist: 198455 Download_button fork
public
Public Clone URL: git://gist.github.com/198455.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#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