Skip to content
Snippets Groups Projects
Commit 0e172b4b authored by Raymond Toy's avatar Raymond Toy
Browse files

Fix #36: encode-universal-time errors on valid time

Allow 1899 as a year, but also add a check that the resulting time is
a non-negative integer.

Add a test for this too in issues.lisp.
parent 63264651
No related branches found
No related tags found
No related merge requests found
...@@ -223,8 +223,11 @@ ...@@ -223,8 +223,11 @@
(type (mod 24) hour) (type (mod 24) hour)
(type (integer 1 31) date) (type (integer 1 31) date)
(type (integer 1 12) month) (type (integer 1 12) month)
(type (or (integer 0 99) (integer 1900)) year) ;; 1899 to account for time zones that are equivalent to 1900.
(type (or null rational) time-zone)) (type (or (integer 0 99) (integer 1899)) year)
(type (or null rational) time-zone)
;; Result must be non-negative integer!
(values (integer 0)))
(let* ((year (if (< year 100) (let* ((year (if (< year 100)
(pick-obvious-year year) (pick-obvious-year year)
year)) year))
......
...@@ -347,3 +347,8 @@ ...@@ -347,3 +347,8 @@
(assert (null (set-difference directories (assert (null (set-difference directories
'(".dir" "dir") '(".dir" "dir")
:test #'string-equal))))) :test #'string-equal)))))
(define-test issue.36
(:tag :issues)
(loop for k from 1 to 24 do
(assert-equal 0 (encode-universal-time 0 0 (- 24 k) 31 12 1899 k))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment