Main Page | Modules | Data Structures | File List | Data Fields

timegm.c

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

←Products
© 2005-2006 - KoanLogic S.r.l. - All rights reserved