]> git.sur5r.net Git - cc65/blob - testcode/lib/time-test.c
New module time-test.c
[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
11     tm.tm_sec   = 9;
12     tm.tm_min   = 34;
13     tm.tm_hour  = 21;
14     tm.tm_mday  = 12;
15     tm.tm_mon   = 10;   /* 0..11, so this is november */
16     tm.tm_year  = 102;  /* year - 1900, so this is 2002 */
17     tm.tm_wday  = 2;    /* Tuesday */
18     tm.tm_isdst = 0;
19
20     /* Convert this broken down time into a time_t and back */
21     t = mktime (&tm);
22     printf ("Test passes if the following lines are\n"
23             "identical:\n");
24     printf ("3DD173D1 - Tue Nov 12 21:34:09 2002\n");
25     printf ("%08lX - %s", t, asctime (&tm));
26     printf ("%08lX - %s", t, asctime (gmtime (&t)));
27
28     return 0;
29 }
30
31
32