dev/c/time_t_2038/gmtime.c

41 lines
585 B
C
Raw Normal View History

2011-12-05 19:13:13 +04:00
#define _XOPEN_SOURCE
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
struct tm t, *tp = NULL;
time_t tt;
char outstr[200];
putenv("TZ=Europe/Moscow");
t.tm_sec = 1;
t.tm_min = 2;
t.tm_hour = 3;
t.tm_mday = 4;
t.tm_mon = 5;
2011-12-06 19:24:38 +04:00
t.tm_year = 1000;
2011-12-05 19:13:13 +04:00
t.tm_isdst = 0;
tt = mktime(&t);
tp = gmtime(&tt);
if (strftime(outstr, sizeof(outstr), "%Y.%m.%d", tp) != 0)
printf("%s\n", outstr);
printf("%d\n", sizeof(time_t));
2011-12-06 19:24:38 +04:00
printf("%lu\n", tt);
printf("%d\n", sizeof(struct tm));
printf("%s\n", asctime(tp));
2011-12-05 19:13:13 +04:00
return 0;
}