From 64bcfff3a12695f4e3f54b0590e896611da71c3b Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 25 Nov 2003 02:11:11 +0000 Subject: More tweaks on Linux and Solaris. --- src/lib9/date.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'src/lib9/date.c') diff --git a/src/lib9/date.c b/src/lib9/date.c index 22ec6721..8ece0c68 100644 --- a/src/lib9/date.c +++ b/src/lib9/date.c @@ -1,18 +1,24 @@ #include /* setenv etc. */ #include +#define NOPLAN9DEFINES #include +#include -#undef gmtime -#undef localtime -#undef asctime -#undef ctime -#undef cputime -#undef times -#undef tm2sec -#undef nsec +#define _HAVETIMEGM 1 +#define _HAVETMZONE 1 +#define _HAVETMTZOFF 1 -#include +#if defined(__linux__) +# undef _HAVETMZONE +# undef _HAVETMTZOFF + +#elif defined(__sun__) +# undef _HAVETIMEGM +# undef _HAVETMZONE +# undef _HAVETMTZOFF + +#endif static Tm bigtm; @@ -80,15 +86,17 @@ timegm(struct tm *tm) { time_t ret; char *tz; + char *s; tz = getenv("TZ"); - setenv("TZ", "", 1); + putenv("TZ="); tzset(); ret = mktime(tm); - if(tz) - setenv("TZ", tz, 1); - else - unsetenv("TZ"); + if(tz){ + s = smprint("TZ=%s", tz); + if(s) + putenv(s); + } return ret; } #endif -- cgit v1.2.3