X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Ftime.lisp;h=18451939657468ce447b6070dc0095a41069cde2;hb=814ef0649edf23f0136d5cad2d7738ae72e79871;hp=32c10b70227f3dfc1950d3a459b8f1b1e506677d;hpb=e567409d9fff3f7231c2a0bb69b345e19de2b246;p=clsql.git diff --git a/sql/time.lisp b/sql/time.lisp index 32c10b7..1845193 100644 --- a/sql/time.lisp +++ b/sql/time.lisp @@ -852,6 +852,9 @@ with the given options" (if stream (write-string string stream) string))) + (:iso8601 + (format stream "~4,'0D-~2,'0D-~2,'0DT~2,'0D:~2,'0D:~2,'0D.~DZ" + year month day hour minute second usec)) (t (format stream "~2,'0D~A~2,'0D~A~2,'0D~A~2,'0D~A~2,'0D~A~2,'0D.~6,'0D" year date-separator month date-separator day @@ -1203,17 +1206,21 @@ rules" timestring starts with P, read a duration; otherwise read an ISO 8601 formatted date string." (declare (ignore junk-allowed)) - (let ((string (subseq timestring start end))) - (if (char= (aref string 0) #\P) - (parse-iso-8601-duration string) - (parse-iso-8601-time string)))) + (if (typep timestring '(or wall-time date)) + timestring + (let ((string (subseq timestring start end))) + (if (char= (aref string 0) #\P) + (parse-iso-8601-duration string) + (parse-iso-8601-time string))))) (defun parse-datestring (datestring &key (start 0) end junk-allowed) "parse a ISO 8601 timestring and return the corresponding date. Will throw a hissy fit if the date string is a duration. Will ignore any precision beyond day (hour/min/sec/usec)." - (let ((parsed-value (parse-timestring datestring :start start :end end :junk-allowed junk-allowed))) - (ecase (type-of parsed-value) - (wall-time (%make-date :mjd (time-mjd parsed-value)))))) + (if (typep datestring '(or wall-time date)) + datestring + (let ((parsed-value (parse-timestring datestring :start start :end end :junk-allowed junk-allowed))) + (ecase (type-of parsed-value) + (wall-time (%make-date :mjd (time-mjd parsed-value))))))) (defvar *iso-8601-duration-delimiters*