diff options
author | Vincent Ambo <tazjin@google.com> | 2019-12-27T01·31+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2019-12-27T11·54+0100 |
commit | 5fd7de921b73c0257b2db90897ad18cc23edded4 (patch) | |
tree | 19896230be5e91dd59676e659df71a1b7ae7552b | |
parent | b48797e4ce27a431dab85009c1603140a5830782 (diff) |
feat(dottime.el): Use dottime in telega.el, too r/308
-rw-r--r-- | tools/emacs-pkgs/dottime/dottime.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/emacs-pkgs/dottime/dottime.el b/tools/emacs-pkgs/dottime/dottime.el index 7caeb2f2c440..b4445d3c0bdc 100644 --- a/tools/emacs-pkgs/dottime/dottime.el +++ b/tools/emacs-pkgs/dottime/dottime.el @@ -56,4 +56,20 @@ (advice-add 'display-time-update :around #'dottime--display-time-update-advice)) (display-time-update)) +;; Amend the time display in telega.el to use dottime. +;; +;; This will never display offsets in the chat window, as those are +;; always visible in the modeline anyways. +(when (-contains? features 'telega) + (defun telega-ins--dottime-advice (orig timestamp) + (let* ((dtime (decode-time timestamp t)) + (current-ts (time-to-seconds (current-time))) + (ctime (decode-time current-ts)) + (today00 (telega--time-at00 current-ts ctime))) + (if (> timestamp today00) + (telega-ins-fmt "%02d·%02d" (nth 2 dtime) (nth 1 dtime)) + (funcall orig timestamp)))) + + (advice-add 'telega-ins--date :around #'telega-ins--dottime-advice)) + (provide 'dottime) |