From 3f3da9b69b51182116195fb644f0f19b1b0ebab6 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Thu, 16 May 2024 09:54:28 +0200 Subject: [PATCH] use local-time for timestamp conversions; + revert: timestamptz in db --- scopes.asd | 2 +- storage/tracking.lisp | 5 +++-- test/test-storage.lisp | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scopes.asd b/scopes.asd index 72bb262..3ac80bf 100644 --- a/scopes.asd +++ b/scopes.asd @@ -6,7 +6,7 @@ :version "0.0.1" :homepage "https://www.cyberconcepts.org" :description "" - :depends-on (:dbi :str :sxql) + :depends-on (:dbi :local-time :str :sxql) :components ((:file "forge/forge") (:file "storage/storage") (:file "storage/tracking" :depends-on ("storage/storage")) diff --git a/storage/tracking.lisp b/storage/tracking.lisp index 4765b85..5da4093 100644 --- a/storage/tracking.lisp +++ b/storage/tracking.lisp @@ -42,7 +42,8 @@ (let ((vl (head-proplist track))) (with-slots ((trid trackid) (ts time-stamp) data) track (if trid (setf (getf vl :trackid) trid)) - (if ts (setf (getf vl :timestamp) ts)) + (if ts (setf (getf vl :timestamp) + (format nil "~a" (local-time:universal-to-timestamp ts)))) (if data (setf (getf vl :data) data))) vl)) @@ -75,7 +76,7 @@ (nconc `((trackid :type ,id-type :primary-key t :not-null t)) hf-def - `((timestamp :type timestamp :not-null t :default current_timestamp) + `((timestamp :type timestamptz :not-null t :default current_timestamp) (data :type ,json-type :not-null t :default |'{}'|))))) (create-indexes st table tn (indexes cont)))) diff --git a/test/test-storage.lisp b/test/test-storage.lisp index d96b94f..c32b413 100644 --- a/test/test-storage.lisp +++ b/test/test-storage.lisp @@ -43,9 +43,11 @@ (storage:drop-table st :testing.tracks) (tracking:create-table cont) (setf tr (tracking:make-item cont "t01" "john")) + (setf (tracking:time-stamp tr) (get-universal-time)) (== (tracking:head tr) '("t01" "john")) (== (tracking:head-proplist tr) '(:username "john" :taskid "t01")) (== (tracking:data tr) nil) (tracking:insert tr) (== (tracking:trackid tr) 1) + (print (local-time:universal-to-timestamp (tracking:time-stamp tr))) ))