timegm.c
00001
00002
00003 #include <u/libu_conf.h>
00004 #include <time.h>
00005
00006 #ifndef HAVE_TIMEGM
00007
00008 #include <stdlib.h>
00009 #include <stdio.h>
00010
00011 time_t timegm(struct tm *tm)
00012 {
00013 time_t ret;
00014 char *tz;
00015
00016
00017 tz = getenv("TZ");
00018 putenv("TZ=UTC");
00019 tzset();
00020
00021 ret = mktime(tm);
00022 if(tz)
00023 {
00024 char buf[256];
00025 snprintf(buf, sizeof(buf), "TZ=%s", tz);
00026 putenv(buf);
00027 } else
00028 putenv("TZ=");
00029 tzset();
00030
00031 return ret;
00032 }
00033
00034 #else
00035 time_t timegm(struct tm*);
00036 #endif