simplify time display a bit

expecting to change this stuff again later
This commit is contained in:
Miranda Marquez 2024-09-09 17:57:52 -08:00
parent 3294ba546e
commit 0d0798e94f

14
p11k.el
View File

@ -212,10 +212,15 @@ time the command took to complete in seconds.
Outputteth a string." Outputteth a string."
;; TIMESTAMP is irrelevant for us ;; TIMESTAMP is irrelevant for us
(let ((durstring (format "%.3fs" duration))) (let ((durstring
(if (> duration p11k/duration-precision-cutoff)
(format "%.0fs" duration)
(format "%.3fs" duration))))
(p11k/spaced-concat (p11k/spaced-concat
(if (eq p11k/prompt-flow 'fluent) "took" "") (if (eq p11k/prompt-flow 'fluent) "took" "")
(propertize durstring 'face 'p11k/yellow)))) (propertize durstring 'face 'p11k/yellow))))
(defvar p11k/duration-precision-cutoff 3)
;; is there a better way to do above? perhaps with Format?
(defun p11k/justificate (left-items right-items) (defun p11k/justificate (left-items right-items)
"Concatenate LEFT-ITEMS and RIGHT-ITEMS with a gap between. "Concatenate LEFT-ITEMS and RIGHT-ITEMS with a gap between.
@ -280,8 +285,11 @@ Use 'window-width' to calculate the total final width."
(p11k/spaced-concat (p11k/spaced-concat
(if (eq p11k/prompt-style 'fluent) "at" "") (if (eq p11k/prompt-style 'fluent) "at" "")
(propertize (pcase p11k/show-current-time (propertize (pcase p11k/show-current-time
(12 (format-time-string "%I:%M:%S %p")) ;; not showing seconds rn
(24 (format-time-string "%H:%M:%S")) (12 (format-time-string "%I:%M %p"))
(24 (format-time-string "%H:%M"))
;; (12 (format-time-string "%I:%M:%S %p"))
;; (24 (format-time-string "%H:%M:%S"))
(t "[bad time type]")) (t "[bad time type]"))
'face 'p11k/cyan)) 'face 'p11k/cyan))
"")) ""))