Hi,
I was playing around with the SLIME inspector and I happened to inspect a slot in a class where I'm storing a universal date. I thought it was nifty that the inspector tried to show me the date in ISO 8601 format. However, I noticed that the date was wrong. Instead of displaying time at "Zulu" as indicated by the Z at the end, it was displaying the time with respect to my current timezone. I did some digging and noticed that the Z was hard coded! Uh oh!
I decided to try to "fix" this problem and make the inspector display the proper ISO 8601 time and include the correct timezone. Thanks to Nikolai Sandved's ISO 8601 page (http://www.pvv.ntnu.no/~nsaa/ISO8601.html), this was easy. I took his format-iso8601-time and included it in swank.lisp. Then, I modified the inspect-for-emacs method that takes an integer to call his format-iso8601-time function. VOILA! Proper dates.
Tom
Index: swank.lisp =================================================================== RCS file: /project/slime/cvsroot/slime/swank.lisp,v retrieving revision 1.309 diff -u -r1.309 swank.lisp --- swank.lisp 21 Jun 2005 18:28:58 -0000 1.309 +++ swank.lisp 23 Jul 2005 21:37:04 -0000 @@ -3659,6 +3659,27 @@ (declare (ignore inspector)) (values "A number." `("Value: " ,(princ-to-string n))))
+(defun format-iso8601-time (time-value &optional include-timezone-p) + "Formats a universal time TIME-VALUE in ISO 8601 format, with 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) + (if (zerop zone) + "Z" + (multiple-value-bind (h m) (truncate (abs zone) 1.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)) + (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))))) + (defmethod inspect-for-emacs ((i integer) inspector) (declare (ignore inspector)) (values "A number." @@ -3671,10 +3692,7 @@ (label-value-line "Length" (integer-length i)) (ignore-errors (list "As time: " - (multiple-value-bind (sec min hour date month year) - (decode-universal-time i) - (format nil "~4,'0D-~2,'0D-~2,'0DT~2,'0D:~2,'0D:~2,'0DZ" - year month date hour min sec))))))) + (format-iso8601-time i t))))))
(defmethod inspect-for-emacs ((c complex) inspector) (declare (ignore inspector))