Raymond Toy pushed to branch master at cmucl / cmucl
Commits: 0e172b4b by Raymond Toy at 2016-11-10T19:13:53-08:00 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.
- - - - -
2 changed files:
- src/code/time.lisp - tests/issues.lisp
Changes:
===================================== src/code/time.lisp ===================================== --- a/src/code/time.lisp +++ b/src/code/time.lisp @@ -223,8 +223,11 @@ (type (mod 24) hour) (type (integer 1 31) date) (type (integer 1 12) month) - (type (or (integer 0 99) (integer 1900)) year) - (type (or null rational) time-zone)) + ;; 1899 to account for time zones that are equivalent to 1900. + (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) (pick-obvious-year year) year))
===================================== tests/issues.lisp ===================================== --- a/tests/issues.lisp +++ b/tests/issues.lisp @@ -347,3 +347,8 @@ (assert (null (set-difference directories '(".dir" "dir") :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))))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/0e172b4b2d6dc5a6dd016c0803...