[Git][cmucl/cmucl][rtoy-issue-26] 3 commits: Fix #36: encode-universal-time errors on valid time

Raymond Toy rtoy at common-lisp.net
Thu Dec 1 03:54:32 UTC 2016


Raymond Toy pushed to branch rtoy-issue-26 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.

- - - - -
fb864a9b by Raymond Toy at 2016-11-30T19:53:44-08:00
Fix merge conflicts with master

- - - - -
8743d581 by Raymond Toy at 2016-11-30T19:53:57-08:00
Fix merge conflicts

- - - - -


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
@@ -348,6 +348,11 @@
                                   '(".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))))
+
 (define-test issue.26
     (:tag :issues)
   (let ((start-time (get-universal-time)))



View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/compare/260c0e45be8064450a13608a9ec4d95d98c4ccfc...8743d581778ba8e63bd6875aba2d37ca988ca22a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20161201/a019db72/attachment-0001.html>


More information about the cmucl-cvs mailing list