Update.
[glibc.git] / time / tst-posixtz.c
blob00a16499f312abdcf7a817f2c85de3a4f94552e5
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <time.h>
6 struct
8 time_t when;
9 const char *tz;
10 const char *result;
11 } tests[] =
13 { 909312849L, "AEST-10AEDST-11,M10.5.0,M3.5.0",
14 "1998/10/25 21:54:09 dst=1 zone=AEDST" },
15 { 924864849L, "AEST-10AEDST-11,M10.5.0,M3.5.0",
16 "1999/04/23 20:54:09 dst=0 zone=AEST" },
19 int
20 main (void)
22 int result = 0;
23 int cnt;
25 for (cnt = 0; cnt < sizeof (tests) / sizeof (tests[0]); ++cnt)
27 char buf[100];
28 struct tm *tmp;
30 printf ("TZ = \"%s\", time = %ld => ", tests[cnt].tz, tests[cnt].when);
31 fflush (stdout);
33 setenv ("TZ", tests[cnt].tz, 1);
35 tmp = localtime (&tests[cnt].when);
37 snprintf (buf, sizeof (buf),
38 "%04d/%02d/%02d %02d:%02d:%02d dst=%d zone=%s",
39 tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
40 tmp->tm_hour, tmp->tm_min, tmp->tm_sec, tmp->tm_isdst,
41 tzname[tmp->tm_isdst ? 1 : 0]);
43 fputs (buf, stdout);
45 if (strcmp (buf, tests[cnt].result) == 0)
46 puts (", OK");
47 else
49 result = 1;
50 puts (", FAIL");
54 return result;