Skip to content

Commit

Permalink
Merge pull request #37 from dcurrie/issue-#34
Browse files Browse the repository at this point in the history
Fix parsetime to initialize timezone, issue #34.
  • Loading branch information
JeffBezanson committed Nov 16, 2016
2 parents 8342f9a + b36d4fb commit 4087d6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llt/timefuncs.c
Expand Up @@ -82,7 +82,7 @@ void timestring(double seconds, char *buffer, size_t len)
{
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;

Expand Down Expand Up @@ -117,6 +117,8 @@ double parsetime(const char *str)

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;
Expand Down
4 changes: 4 additions & 0 deletions tests/unittest.lsp
Expand Up @@ -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

0 comments on commit 4087d6a

Please sign in to comment.