aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--skeletons/GeneralizedTime.c14
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;
}