From 3c14b8b5ceb2696e623ea2e8a0cd85e0c8e1b278 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Wed, 12 Mar 2014 17:00:07 -0600 Subject: [PATCH] libcsa: fix up some stupidness. --- cde/lib/csa/iso8601.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cde/lib/csa/iso8601.c b/cde/lib/csa/iso8601.c index 55991923..1252fba5 100644 --- a/cde/lib/csa/iso8601.c +++ b/cde/lib/csa/iso8601.c @@ -29,6 +29,10 @@ */ #include +#define XOS_USE_NO_LOCKING +#define X_INCLUDE_TIME_H +#include + #include #include #include @@ -42,12 +46,12 @@ set_timezone(char *tzname) static char tzenv[BUFSIZ]; if (tzname==NULL) - system("unset TZ\n"); + (void) putenv("TZ"); else { snprintf(tzenv, sizeof tzenv, "TZ=%s", tzname); (void) putenv(tzenv); - tzset(); } + tzset(); } static int @@ -166,12 +170,16 @@ _csa_tick_to_iso8601(time_t tick, char *buf_out) time_t tk=tick; char tz_orig[BUFSIZ]; boolean_t orig_tzset = B_FALSE; + _Xgtimeparams gmtime_buf; /* tick must be +ve to be valid */ if (tick < 0) { return(-1); } + /* JET. This is horrible. */ +#if !defined(linux) && !defined(CSRG_BASED) + if (getenv("TZ")) { strncpy(tz_orig, getenv("TZ"), sizeof(tz_orig)); tz_orig[sizeof(tz_orig)-1] = '\0'; @@ -191,6 +199,11 @@ _csa_tick_to_iso8601(time_t tick, char *buf_out) else set_timezone(NULL); +#else + /* let's use something a little more reasonable */ + time_str = _XGmtime(&tk, gmtime_buf); +#endif /* !linux && !CSGRC_BASED */ + /* format string forces fixed width (zero-padded) fields */ sprintf(buf_out, "%04d%02d%02dT%02d%02d%02dZ", time_str->tm_year + 1900, -- 2.25.1