about summary refs log tree commit diff
path: root/lisp/klatre
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-05-29T13·50+0200
committersterni <sternenseemann@systemli.org>2021-05-29T19·13+0000
commitf60d174591a2fdf3de8fe96b9f3bb890a000bfe8 (patch)
treeff17fbc6dd0d198c5bc5730ef4f7d0305ae39572 /lisp/klatre
parentb36a75a22360b351bdc9dffb35aca65add28abd4 (diff)
feat(klatre): expose utility to format dot time offset r/2632
Turns out this is an annoying thingy you sometimes to implement
independently from formatting an entire timestamp, so we expose it for
reuse.

Change-Id: I11de2823eb03849ea78fc79e2f546e413882930f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3163
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'lisp/klatre')
-rw-r--r--lisp/klatre/klatre.lisp6
-rw-r--r--lisp/klatre/package.lisp2
2 files changed, 7 insertions, 1 deletions
diff --git a/lisp/klatre/klatre.lisp b/lisp/klatre/klatre.lisp
index e10ddeea4e35..7fb70463a632 100644
--- a/lisp/klatre/klatre.lisp
+++ b/lisp/klatre/klatre.lisp
@@ -86,6 +86,12 @@ separated by SEP."
     (local-time:format-timestring nil timestamp
                                   :format dottime-format
                                   :timezone local-time:+utc-zone+)
+    (format-dottime-offset offset)))
+
+(defun format-dottime-offset (offset)
+  "Render OFFSET in hours in the format specified by dottime."
+  (check-type offset integer)
+  (concatenate 'string
     ; render sign manually since format prints it after padding
     (if (>= offset 0) "+" "-")
     (format nil "~2,'0D" (abs offset))))
diff --git a/lisp/klatre/package.lisp b/lisp/klatre/package.lisp
index 21f659ef18b1..41174bbb3cf7 100644
--- a/lisp/klatre/package.lisp
+++ b/lisp/klatre/package.lisp
@@ -10,7 +10,7 @@
 
    ;; String handling
    #:+dottime-format+ #:format-dottime
-   #:try-parse-integer
+   #:try-parse-integer #:format-dottime-offset
 
    ;; Function utilities
    #:partial))