From 5fd7de921b73c0257b2db90897ad18cc23edded4 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 27 Dec 2019 02:31:42 +0100 Subject: feat(dottime.el): Use dottime in telega.el, too --- tools/emacs-pkgs/dottime/dottime.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tools') 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) -- cgit 1.4.1