From 3895690af1045315a82a216fabe312d1a7e67dc5 Mon Sep 17 00:00:00 2001 From: Russ Tyndall Date: Thu, 9 Oct 2008 14:30:22 -0400 Subject: [PATCH] added some generic postegres code to send times to the database as iso8601 --- sql/generic-postgresql.lisp | 8 ++++++++ sql/time.lisp | 3 +++ 2 files changed, 11 insertions(+) diff --git a/sql/generic-postgresql.lisp b/sql/generic-postgresql.lisp index 360d5fe..5498ee2 100644 --- a/sql/generic-postgresql.lisp +++ b/sql/generic-postgresql.lisp @@ -29,6 +29,14 @@ (declare (ignore database db-type)) val) +(defmethod database-output-sql ((self wall-time) (database generic-postgresql-database)) + (declare (ignore database)) + (concatenate 'string "'" (format-time nil self :format :iso8601) "'")) + +(defmethod database-output-sql ((self date) (database generic-postgresql-database)) + (declare (ignore database)) + (concatenate 'string "'" (format-time nil (date->time self) :format :iso8601) "'")) + (defmethod database-get-type-specifier (type args database (db-type (eql :postgresql))) (declare (ignore type args database)) diff --git a/sql/time.lisp b/sql/time.lisp index 32c10b7..4e8b6af 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 -- 2.34.1