]> git.sur5r.net Git - cc65/blob - testcode/lib/time-test.c
un-remove TABs in doc/using-make.sgml
[cc65] / testcode / lib / time-test.c
1 #include <stdio.h>
2 #include <time.h>
3
4
5
6 int main (void)
7 {
8     struct tm tm;
9     time_t t;
10     char   buf[64];
11
12
13     tm.tm_sec   = 9;
14     tm.tm_min   = 34;
15     tm.tm_hour  = 21;
16     tm.tm_mday  = 12;
17     tm.tm_mon   = 10;   /* 0..11, so this is november */
18     tm.tm_year  = 102;  /* year - 1900, so this is 2002 */
19     tm.tm_wday  = 2;    /* Tuesday */
20     tm.tm_isdst = 0;
21
22     /* Convert this broken down time into a time_t and back */
23     t = mktime (&tm);
24     printf ("Test passes if the following lines are\n"
25             "all identical:\n");
26     printf ("3DD173D1 - Tue Nov 12 21:34:09 2002\n");
27     printf ("%08lX - %s", t, asctime (&tm));
28     printf ("%08lX - %s", t, asctime (gmtime (&t)));
29     strftime (buf, sizeof (buf), "%c", &tm);
30     printf ("%08lX - %s\n", t, buf);
31     strftime (buf, sizeof (buf), "%a %b %d %H:%M:%S %Y", &tm);
32     printf ("%08lX - %s\n", t, buf);
33
34     return 0;
35 }
36
37
38