From cfe66a259bc373c81e80e60835323f3fea929b7d Mon Sep 17 00:00:00 2001 From: Andy Keep Date: Fri, 29 Apr 2016 00:43:06 -0400 Subject: [PATCH] - fixed date->time-utc to honor the zone-offset field when converting a date object to a time-utc object. stats.c, date.ms original commit: 63a97939896c2a89fcffdf16c8b783efaeb816b5 --- .gitignore | 3 +++ LOG | 4 ++++ c/stats.c | 2 ++ mats/date.ms | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/.gitignore b/.gitignore index 84ca7f1407..a13d63d9d3 100755 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ /ti3nt/ /ti3osx/ Makefile +.*.sw? +.sw? +bin diff --git a/LOG b/LOG index 32a00f8ac3..b6989a271e 100644 --- a/LOG +++ b/LOG @@ -55,3 +55,7 @@ - fixed time-utc->date test in mat time&date-printing to work regardless of what locale (and time zone) the host machine has set. date.ms +- fixed date->time-utc to honor the zone-offset field when converting a date + object to a time-utc object. + stats.c, + date.ms diff --git a/c/stats.c b/c/stats.c index d50e3f259f..85ba9b39bb 100644 --- a/c/stats.c +++ b/c/stats.c @@ -375,6 +375,7 @@ ptr S_asctime(ptr dtvec) { ptr S_mktime(ptr dtvec) { time_t tx; struct tm tmx; + long orig_tzoff = (long)UNFIX(INITVECTIT(dtvec, dtvec_tzoff)); tmx.tm_sec = (int)Sinteger_value(Svector_ref(dtvec, dtvec_sec)); tmx.tm_min = (int)Sinteger_value(Svector_ref(dtvec, dtvec_min)); @@ -405,6 +406,7 @@ 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); + if (tmx.tm_gmtoff != orig_tzoff) tx = difftime(tx, (time_t)(orig_tzoff - tmx.tm_gmtoff)); return Scons(S_integer_time_t(tx), Svector_ref(dtvec, dtvec_nsec)); } diff --git a/mats/date.ms b/mats/date.ms index eebeac5f05..a71873ac27 100644 --- a/mats/date.ms +++ b/mats/date.ms @@ -556,6 +556,10 @@ (let ([t (current-time 'time-utc)]) (sleep (make-time 'time-duration 0 1)) (timetime-utc (current-date)))) + (let ([t (current-time)]) + (time=? + (date->time-utc (time-utc->date t -14400)) + (date->time-utc (time-utc->date t 0)))) ) (mat time&date-printing