about summary refs log tree commit diff
path: root/tools/emacs-pkgs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-12-27T01·31+0100
committerVincent Ambo <tazjin@google.com>2019-12-27T11·54+0100
commit5fd7de921b73c0257b2db90897ad18cc23edded4 (patch)
tree19896230be5e91dd59676e659df71a1b7ae7552b /tools/emacs-pkgs
parentb48797e4ce27a431dab85009c1603140a5830782 (diff)
feat(dottime.el): Use dottime in telega.el, too r/308
Diffstat (limited to 'tools/emacs-pkgs')
-rw-r--r--tools/emacs-pkgs/dottime/dottime.el16
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)