diff options
author | sterni <sternenseemann@systemli.org> | 2021-01-19T13·43+0100 |
---|---|---|
committer | sterni <sternenseemann@systemli.org> | 2021-01-25T20·09+0000 |
commit | 71946b84b8a9ffba3a9fa627f34e5dbabec50b4b (patch) | |
tree | 29c3eb8b838a1d1bc14ac45d3521faecee71c653 /lisp/klatre | |
parent | cf4357d9b7a0ce2e885bd7e4d11412c92517d19b (diff) |
feat(klatre): support offsets in format-dottime r/2142
Instead of bothering with local-time's feature rich timezone support we just pass the offset as an integer and render it ourselves. Change-Id: I1df2d02153e3ef21ae3b2871ad6ef57d0f6eff86 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2423 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'lisp/klatre')
-rw-r--r-- | lisp/klatre/klatre.lisp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lisp/klatre/klatre.lisp b/lisp/klatre/klatre.lisp index 1c8d4c4d2e5b..e10ddeea4e35 100644 --- a/lisp/klatre/klatre.lisp +++ b/lisp/klatre/klatre.lisp @@ -76,18 +76,23 @@ separated by SEP." (defparameter dottime-format '((:year 4) #\- (:month 2) #\- (:day 2) #\T - (:hour 2) #\· (:min 2) "+00") ; TODO(grfn): Allow passing offset + (:hour 2) #\· (:min 2)) "`:LOCAL-TIME' format specifier for dottime") -(defun format-dottime (timestamp) - "Return TIMESTAMP formatted as dottime, using a +00 offset" +(defun format-dottime (timestamp &optional (offset 0)) + "Return TIMESTAMP formatted as dottime, with a specified offset or +00" (check-type timestamp local-time:timestamp) - (local-time:format-timestring nil timestamp - :format dottime-format - :timezone local-time:+utc-zone+)) + (concatenate 'string + (local-time:format-timestring nil timestamp + :format dottime-format + :timezone local-time:+utc-zone+) + ; render sign manually since format prints it after padding + (if (>= offset 0) "+" "-") + (format nil "~2,'0D" (abs offset)))) (comment - (format-dottime (local-time:now))) + (format-dottime (local-time:now)) + (format-dottime (local-time:now) 2)) (defun try-parse-integer (str) "Attempt to parse STR as an integer, returning nil if it is invalid." |