From 820f7bccb9d52c5df0a6488b7289ad387a3145cb Mon Sep 17 00:00:00 2001 From: Andy Keep Date: Sun, 15 May 2016 00:16:15 -0400 Subject: [PATCH] - updated the fix to S_mktime to work on windows. the struct tm structure on windows does not have the tm_gmtoff field used in the mac and linux version of the code. stats.c original commit: 4339b856d85de4c949ef7c4e66ec679512809a58 --- LOG | 4 ++++ c/stats.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/LOG b/LOG index 7f825f1642..c407f147e3 100644 --- a/LOG +++ b/LOG @@ -144,3 +144,7 @@ use.stex - updated to curl stex version 1.2.1 configure +- updated the fix to S_mktime to work on windows. the struct tm + structure on windows does not have the tm_gmtoff field used in the + mac and linux version of the code. + stats.c diff --git a/c/stats.c b/c/stats.c index 85ba9b39bb..cd57e58bab 100644 --- a/c/stats.c +++ b/c/stats.c @@ -406,7 +406,26 @@ ptr S_mktime(ptr dtvec) { INITVECTIT(dtvec, dtvec_year) = Sinteger(tmx.tm_year); INITVECTIT(dtvec, dtvec_wday) = Sinteger(tmx.tm_wday); INITVECTIT(dtvec, dtvec_yday) = Sinteger(tmx.tm_yday); +#ifdef WIN32 + { + TIME_ZONE_INFORMATION tz; + DWORD rc = GetTimeZoneInformation(&tz); + long tzoff; + + switch (rc) { + case TIME_ZONE_ID_UNKNOWN: + case TIME_ZONE_ID_STANDARD: + tzoff = tz.Bias * -60; + break; + case TIME_ZONE_ID_DAYLIGHT: + tzoff = (tz.Bias + tz.DaylightBias) * -60; + break; + } + if (tzoff != orig_tzoff) tx = (time_t) difftime(tx, (time_t)(orig_tzoff - tzoff)); + } +#else if (tmx.tm_gmtoff != orig_tzoff) tx = difftime(tx, (time_t)(orig_tzoff - tmx.tm_gmtoff)); +#endif return Scons(S_integer_time_t(tx), Svector_ref(dtvec, dtvec_nsec)); }