From 094055ce16c61b63ff5f92814d4d1b4ecec2a9ee Mon Sep 17 00:00:00 2001 From: Nathan Bird Date: Wed, 3 Feb 2010 10:07:17 -0500 Subject: [PATCH] Time printing bugfixes- Use a #\T to separate date and time per iso standard. Thanks to Harald Hanche-Olsen for the report http://lists.b9.com/pipermail/clsql/2010-February/001836.html --- sql/time.lisp | 4 ++-- tests/test-time.lisp | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/sql/time.lisp b/sql/time.lisp index 51cbcbe..83e17a0 100644 --- a/sql/time.lisp +++ b/sql/time.lisp @@ -447,8 +447,8 @@ (princ month stream) (princ #\- stream) (when (< day 10) (princ #\0 stream)) - (princ month stream) - (princ #\space stream) + (princ day stream) + (princ #\T stream) ;strict ISO says T here isn't optional. (when (< hour 10) (princ #\0 stream)) (princ hour stream) (princ #\: stream) diff --git a/tests/test-time.lisp b/tests/test-time.lisp index 5d2e2e5..174ab75 100644 --- a/tests/test-time.lisp +++ b/tests/test-time.lisp @@ -69,6 +69,25 @@ (decode-time time1)) 3 32 56 14 23 1 2010 6) +(deftest :time/print-parse/1 + ;;make sure when we print and parse we get the same time. + (let* ((time (clsql-sys:make-time :year 2010 :month 1 :day 4 + :hour 14 :minute 15 :second 44)) + (string-time (iso-timestring time)) + (time2 (parse-timestring string-time))) + (decode-time time2)) + 0 44 15 14 4 1 2010 1) + +(deftest :time/print-parse/2 + ;;make sure when we print and parse we get the same time. + (let* ((time (clsql-sys:make-time :year 2010 :month 1 :day 4 + :hour 14 :minute 15 :second 44 :usec 3)) + (string-time (iso-timestring time)) + (time2 (parse-timestring string-time))) + (decode-time time2)) + 3 44 15 14 4 1 2010 1) + + ;; relations of intervals (deftest :time/1 (let* ((time-1 (clsql:parse-timestring "2002-01-01 10:00:00")) @@ -273,17 +292,6 @@ t) -(deftest :time/14-usec - ;;make sure when we print and parse we get the same time. - (let* ((time (clsql-sys:make-time :year 2010 :month 1 :day 4 - :hour 14 :minute 15 :second 44 :usec 3)) - (string-time (clsql-sys:format-time nil time :format :iso)) - (time2 (clsql-sys:parse-timestring string-time))) - (format-time nil time2 :format :iso)) - #.(format-time nil (clsql-sys:make-time :year 2010 :month 1 :day 4 - :hour 14 :minute 15 :second 44 :usec 3) - :format :iso)) - ;;; The cross platform dataset uses the 'timestamp' column type which is ;;; in sql-92, for all that means. -- 2.34.1