diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-07-22T02·07-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-07-23T00·08+0000 |
commit | f591c32dfb2a9f0246c8d6501c1efab4c80da52f (patch) | |
tree | b677488b378902a6721c570d4be54a49be3326cf | |
parent | d60c639162e8390397b6808f78ac4e2def9324cb (diff) |
feat(klatre): add dottime-format function r/1422
Add a function to klatre format a timestamp using dottime Change-Id: I24d8d91f49f352b606f44834f7229ab55b55afa0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1344 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Reviewed-by: kanepyork <rikingcoding@gmail.com>
-rw-r--r-- | lisp/klatre/default.nix | 4 | ||||
-rw-r--r-- | lisp/klatre/klatre.lisp | 20 | ||||
-rw-r--r-- | lisp/klatre/package.lisp | 5 |
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)) |