about summary refs log tree commit diff
path: root/lisp/klatre/klatre.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/klatre/klatre.lisp')
-rw-r--r--lisp/klatre/klatre.lisp20
1 files changed, 20 insertions, 0 deletions
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)))