diff options
author | Lev Walkin <vlm@lionet.info> | 2004-08-12 07:47:03 +0000 |
---|---|---|
committer | Lev Walkin <vlm@lionet.info> | 2004-08-12 07:47:03 +0000 |
commit | e730f2b863f9808a5703672e4888fb836e45bc10 (patch) | |
tree | 892568321e81e4f7dd4abf4358b7fecfa59bf7c2 | |
parent | db42400f4e7190650cc12ec62bef20da09f8d7a9 (diff) |
portability
-rw-r--r-- | skeletons/GeneralizedTime.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c index f17b4393..4d1b3908 100644 --- a/skeletons/GeneralizedTime.c +++ b/skeletons/GeneralizedTime.c @@ -36,15 +36,19 @@ static struct tm *gmtime_r(time_t *tloc, struct tm *result) { static time_t timegm(struct tm *tm) { time_t tloc; char *tz; + char *buf; tz = getenv("TZ"); - setenv("TZ", "", 1); + _putenv("TZ=UTC"); tzset(); tloc = mktime(tm); - if (tz) - setenv("TZ", tz, 1); - else - unsetenv("TZ"); + if (tz) { + buf = alloca(strlen(tz) + 4); + sprintf(buf, "TZ=%s", tz); + } else { + buf = "TZ="; + } + _putenv(buf); tzset(); return tloc; } |