diff options
author | Lev Walkin <vlm@lionet.info> | 2004-08-12 03:58:25 +0000 |
---|---|---|
committer | Lev Walkin <vlm@lionet.info> | 2004-08-12 03:58:25 +0000 |
commit | db42400f4e7190650cc12ec62bef20da09f8d7a9 (patch) | |
tree | 834604d5543e06682a40907f1d6a6eae0aa3632b /skeletons | |
parent | 02a315573749209b2f8ca1394ecbc65a53236758 (diff) |
portability
Diffstat (limited to 'skeletons')
-rw-r--r-- | skeletons/GeneralizedTime.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c index c9b05de5..f17b4393 100644 --- a/skeletons/GeneralizedTime.c +++ b/skeletons/GeneralizedTime.c @@ -32,6 +32,24 @@ static struct tm *gmtime_r(time_t *tloc, struct tm *result) { return 0; } +#define tzset() _tzset() +static time_t timegm(struct tm *tm) { + time_t tloc; + char *tz; + + tz = getenv("TZ"); + setenv("TZ", "", 1); + tzset(); + tloc = mktime(tm); + if (tz) + setenv("TZ", tz, 1); + else + unsetenv("TZ"); + tzset(); + return tloc; +} + +#if 0 /* Alternate version */ /* vlm: I am not sure about validity of this algorithm. */ static time_t timegm(struct tm *tm) { struct tm tmp; @@ -42,7 +60,7 @@ static time_t timegm(struct tm *tm) { tm->tm_gmtoff = 0; /* Simulate GMT */ return tloc; } - +#endif #endif /* WIN32 */ #ifndef __NO_ASN_TABLE__ |