[slime-devel] bug in timezone formatting

Vincent Arkesteijn vincent at arkesteijn.net
Tue Sep 13 11:38:53 UTC 2005


Hi,

When inspecting an integer, one of its interpretations is as a universal
time, which is decoded and printed in iso 8601 format.

For example,
   C-c I (get-universal-time)
showed:
   As time: 2005-09-13T00:43:42+01:00

Unfortunately, the indicated number of minutes in the timezone is
always 00 or 01, which is problematic when the timezone offset from
UTC is not an integer number of hours.

Also, the dst return value from decode-universal-time is ignored,
leading to a one-hour error when DST is in effect.

Fix attached.

Vincent.
-------------- next part --------------
2005-09-13  Vincent Arkesteijn  <vincent at arkesteijn.net>

	* swank.lisp (format-iso8601-time): Fix bug: printed timezone
	was off by one hour during DST. Fix bug: printed timezone always
	had number of minutes set to 00 or 01.
-------------- next part --------------
Index: swank.lisp
===================================================================
RCS file: /project/slime/cvsroot/slime/swank.lisp,v
retrieving revision 1.330
diff -u -F^(def -r1.330 swank.lisp
--- swank.lisp	5 Sep 2005 13:54:02 -0000	1.330
+++ swank.lisp	13 Sep 2005 09:02:28 -0000
@@ -3795,20 +3795,24 @@ (defun format-iso8601-time (time-value &
     the time zone included if INCLUDE-TIMEZONE-P is non-NIL"    
     ;; Taken from http://www.pvv.ntnu.no/~nsaa/ISO8601.html
     ;; Thanks, Nikolai Sandved and Thomas Russ!
-    (flet ((format-iso8601-timezone (zone)
+    (flet ((format-iso8601-timezone (zone dst)
+             (when dst
+               (decf zone))
              (if (zerop zone)
                  "Z"
-                 (multiple-value-bind (h m) (truncate (abs zone) 1.0)
+                 (multiple-value-bind (h m) (truncate
+                                              (round (* (abs zone) 60))
+                                              60.0)
                    ;; Tricky.  Sign of time zone is reversed in ISO 8601
                    ;; relative to Common Lisp convention!
                    (format nil "~:[+~;-~]~2,'0D:~2,'0D"
                            (> zone 0) h (round m))))))
     (multiple-value-bind (second minute hour day month year dow dst zone)
       (decode-universal-time time-value)
-      (declare (ignore dow dst))
+      (declare (ignore dow))
       (format nil "~4,'0D-~2,'0D-~2,'0DT~2,'0D:~2,'0D:~2,'0D~:[~*~;~A~]"
               year month day hour minute second
-              include-timezone-p (format-iso8601-timezone zone)))))
+              include-timezone-p (format-iso8601-timezone zone dst)))))
 
 (defmethod inspect-for-emacs ((i integer) inspector)
   (declare (ignore inspector))


More information about the slime-devel mailing list