Ticket #19047: foo.c

File foo.c, 862 bytes (added by bhaible, 2 months ago)

test case foo.c

Line 
1#include <stdio.h>
2#include <string.h>
3#include <time.h>
4#include <assert.h>
5
6int
7main ()
8{
9 time_t t = 1509000003; /* 2017-10-26 06:40:03 */
10 struct tm tm;
11 struct tm *result = gmtime_r (&t, &tm);
12 assert (result == &tm);
13 assert (result->tm_sec == 3);
14 assert (result->tm_min == 40);
15 assert (result->tm_hour == 6);
16 assert (result->tm_mday == 26);
17 assert (result->tm_mon == 10 - 1);
18 assert (result->tm_year == 2017 - 1900);
19 assert (result->tm_wday == 4);
20 assert (result->tm_yday == 298);
21 assert (result->tm_isdst == 0);
22
23 assert (result->tm_gmtoff == 0);
24
25 printf ("tm_zone = %s\n", result->tm_zone == NULL ? "(null)" : result->tm_zone);
26 assert (strcmp (result->tm_zone, "GMT") == 0 /* glibc, NetBSD, OpenBSD, Minix, Cygwin, Android */
27 || strcmp (result->tm_zone, "UTC") == 0 /* musl, macOS, FreeBSD */);
28
29 printf ("OK\n");
30}