* sysdeps/unix/sysv/linux/i386/dl-sysdep.h: Define
[glibc.git] / time / tst-mktime.c
blob416a85616cd122ebd470d5a057d78785632f0cd0
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <time.h>
6 int
7 main (void)
9 struct tm time_str, *tm;
10 time_t t;
11 char daybuf[20];
12 int result;
14 time_str.tm_year = 2001 - 1900;
15 time_str.tm_mon = 7 - 1;
16 time_str.tm_mday = 4;
17 time_str.tm_hour = 0;
18 time_str.tm_min = 0;
19 time_str.tm_sec = 1;
20 time_str.tm_isdst = -1;
22 if (mktime (&time_str) == -1)
24 (void) puts ("-unknown-");
25 result = 1;
27 else
29 (void) strftime (daybuf, sizeof (daybuf), "%A", &time_str);
30 (void) puts (daybuf);
31 result = strcmp (daybuf, "Wednesday") != 0;
34 setenv ("TZ", "EST+5", 1);
35 #define EVENING69 1 * 60 * 60 + 2 * 60 + 29
36 t = EVENING69;
37 tm = localtime (&t);
38 if (tm == NULL)
40 (void) puts ("localtime returned NULL");
41 result = 1;
43 else
45 time_str = *tm;
46 t = mktime (&time_str);
47 if (t != EVENING69)
49 printf ("mktime returned %ld, expected %d\n",
50 (long) t, EVENING69);
51 result = 1;
53 else
54 (void) puts ("Dec 31 1969 EST test passed");
56 setenv ("TZ", "CET-1", 1);
57 t = mktime (&time_str);
58 #define EVENING69_CET (EVENING69 - (5 - -1) * 60 * 60)
59 if (t != EVENING69_CET)
61 printf ("mktime returned %ld, expected %ld\n",
62 (long) t, (long) EVENING69_CET);
63 result = 1;
65 else
66 (void) puts ("Dec 31 1969 CET test passed");
69 return result;