From 1f204f2891038bfced0b799837764495d351f1a5 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 14 Dec 2019 13:22:28 +0000 Subject: feat(emacs.d): Display modeline time in dottime See dotti.me for more information about dottime. <3 edef --- tools/emacs/init/look-and-feel.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tools/emacs/init') diff --git a/tools/emacs/init/look-and-feel.el b/tools/emacs/init/look-and-feel.el index 3d480bd5f43e..9402e09e5620 100644 --- a/tools/emacs/init/look-and-feel.el +++ b/tools/emacs/init/look-and-feel.el @@ -31,6 +31,20 @@ (when (equal "adho" (system-name)) (setq battery-mode-line-format " %b%p%%") (display-battery-mode)) +;; Display modeline time in dottime (see https://dotti.me) +;; +;; This is done in a way that initially seems more complicated than +;; one would like, but this is unfortunately required due to the way +;; `format-time-string' handles timezones. +(defun format-dottime-advice (orig _ &optional _ _) + (let* ((offset-sec (car (current-time-zone))) + (offset-hours (/ offset-sec 60 60)) + (dottime (if (/= offset-hours 0) + (concat "%M-%Dt%H·%M" (format "%0+3d" offset-hours)) + "%m-%dT%H·%M"))) + (apply orig '("%m-%dT%H·%M" nil t)))) + +(advice-add 'format-time-string :around #'format-dottime-advice) ;; Configure telephone-line (defun telephone-misc-if-last-window () -- cgit 1.4.1