aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-10-25 10:00:58 -0500
committerColin Okay <colin@cicadas.surf>2022-10-25 10:00:58 -0500
commit369912230263eb2cd10df336f9e0e9db13e5a7ff (patch)
tree770a109c6ee19489c3980b1115e3f444464c9751
parent89bf6defc5cbe6c049b9901950859fcda4f63f7c (diff)
Add: secs-to-hms util
-rw-r--r--utilities.lisp12
1 files changed, 12 insertions, 0 deletions
diff --git a/utilities.lisp b/utilities.lisp
index abe10b7..96f391c 100644
--- a/utilities.lisp
+++ b/utilities.lisp
@@ -96,3 +96,15 @@
(defun read-from-file (path)
(read-from-string
(alexandria:read-file-into-string path)))
+
+
+(defun secs-to-hms (secs)
+ (let ((hours (floor (/ secs (* 60 60))))
+ (mins (floor (/ (mod secs (* 60 60))
+ 60)))
+ (secs (mod secs 60)))
+ (if (plusp hours)
+ (format nil "~a:~2,'0d:~2,'0d"
+ hours mins secs)
+ (format nil "~a:~2,'0d"
+ mins secs))))