shithub: femtolisp

Download patch

ref: b36d4fbf5ddc57fdcecffe441d1a10669816417b
parent: 8342f9a1e9bfc9f6db3253c5d633c2c77ffd6680
author: Doug Currie <github.9.eeeeeee@spamgourmet.com>
date: Wed Nov 16 05:52:58 EST 2016

Fix parsetime to initialize timezone, issue #34.

--- a/llt/timefuncs.c
+++ b/llt/timefuncs.c
@@ -82,7 +82,7 @@
 {
     time_t tme = (time_t)seconds;
 
-#ifdef LINUX
+#if defined(LINUX) || defined(MACOSX) || defined(OPENBSD) || defined(FREEBSD)
     char *fmt = "%c"; /* needed to suppress GCC warning */
     struct tm tm;
 
@@ -117,6 +117,8 @@
 
     res = strptime(str, fmt, &tm);
     if (res != NULL) {
+        tm.tm_isdst = -1; /* Not set by strptime(); tells mktime() to determine
+                            whether daylight saving time is in effect */
         t = mktime(&tm);
         if (t == ((time_t)-1))
             return -1;
--- a/tests/unittest.lsp
+++ b/tests/unittest.lsp
@@ -283,5 +283,9 @@
 (assert (not (equal? (hash (iota 41))
 		     (hash (iota 42)))))
 
+(if (top-level-bound? 'time.fromstring)
+    (assert (let ((ts (time.string (time.now))))
+                (eqv? ts (time.string (time.fromstring ts))))))
+
 (princ "all tests pass\n")
 #t