diff --git a/lisp/klatre/default.nix b/lisp/klatre/default.nix index 41c3ef809..2c7bb6490 100644 --- a/lisp/klatre/default.nix +++ b/lisp/klatre/default.nix @@ -3,6 +3,10 @@ depot.nix.buildLisp.library { name = "klatre"; + deps = with depot.third_party.lisp; [ + local-time + ]; + srcs = [ ./package.lisp ./klatre.lisp diff --git a/lisp/klatre/klatre.lisp b/lisp/klatre/klatre.lisp index afe16a90b..231e72b64 100644 --- a/lisp/klatre/klatre.lisp +++ b/lisp/klatre/klatre.lisp @@ -68,3 +68,23 @@ separated by SEP." (vector-push-extend (char sep (the fixnum k)) vs)))) lst) vs)) + +;;; +;;; String handling +;;; + +(defconstant +dottime-format+ + '((:year 4) #\- (:month 2) #\- (:day 2) + #\T + (:hour 2) #\ยท (:min 2) "+00") ; TODO(grfn): Allow passing offset + "`:LOCAL-TIME' format specifier for dottime") + +(defun format-dottime (timestamp) + "Return TIMESTAMP formatted as dottime, using a +00 offset" + (check-type timestamp local-time:timestamp) + (local-time:format-timestring nil timestamp + :format +dottime-format+ + :timezone local-time:+utc-zone+)) + +(comment + (format-dottime (local-time:now))) diff --git a/lisp/klatre/package.lisp b/lisp/klatre/package.lisp index 0cf7336fe..b5f574fa1 100644 --- a/lisp/klatre/package.lisp +++ b/lisp/klatre/package.lisp @@ -6,4 +6,7 @@ #:comment #:posp ;; Sequence functions - #:chunk-list #:mapconcat)) + #:chunk-list #:mapconcat + + ;; String handling + #:+dottime-format+ #:format-dottime))