X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Ftime.c;h=82ffab2c528e20b0d2a8e608413b606de695ce23;hb=c2ac5ba3964165ee2d21ccd4c6bf8bdc48e1a165;hp=59e9d1efa27150a3bd23fb3a52a20ff8bf6f1cf9;hpb=cf4cb9554515c59eddbde38d1cf236339c37f55f;p=sbcl.git diff --git a/src/runtime/time.c b/src/runtime/time.c index 59e9d1e..82ffab2 100644 --- a/src/runtime/time.c +++ b/src/runtime/time.c @@ -23,14 +23,28 @@ void get_timezone(time_t when, int *secwest, boolean *dst) struct tm ltm, gtm; int sw; +#ifdef LISP_FEATURE_WIN32 + /* No _r versions on Windows, but the API documentation also + * doesn't warn them about being non-reentrant... So here's + * hoping they actually are -- once Windows grows threads + * this better be checked, though. + * + * The Windows versions also don't support times before the + * epoch, so we kludge it. */ + if (when < 0) + when = 0; ltm = *localtime(&when); gtm = *gmtime(&when); +#else + ltm = *localtime_r(&when, <m); + gtm = *gmtime_r(&when, >m); +#endif sw = (((gtm.tm_hour*60)+gtm.tm_min)*60+gtm.tm_sec) - (((ltm.tm_hour*60)+ltm.tm_min)*60+ltm.tm_sec); if ((gtm.tm_wday + 1) % 7 == ltm.tm_wday) - sw -= 24*3600; + sw -= 24*3600; else if (gtm.tm_wday == (ltm.tm_wday + 1) % 7) - sw += 24*3600; + sw += 24*3600; *secwest = sw; *dst = ltm.tm_isdst; }