about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lisp/klatre/default.nix4
-rw-r--r--lisp/klatre/klatre.lisp20
-rw-r--r--lisp/klatre/package.lisp5
3 files changed, 28 insertions, 1 deletions
diff --git a/lisp/klatre/default.nix b/lisp/klatre/default.nix
index 41c3ef8094d0..2c7bb6490a9f 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 afe16a90b81a..231e72b64f42 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 0cf7336feb06..b5f574fa16c6 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))