Subject: bug#79217: [PATCH] display-time-mode: Include world-clock time in mode line.

From: Wilko Meyer <[email-masked]>
Date: Mon, 11 Aug 2025 16:00:15 +0200

Hi,

This patch introduces an user option to conditionally include
world-clock time, in addition to the localtime, when display-time-mode is
active, in mode line. Right now time in different timezones is only
available in a separate world-clock buffer, having this information
included in the mode line would be useful in my book. WDYT?

I'm not sure if I already have assigned copyright to the FSF before,
so I'll do that within the next hours as required.

>From ac5e6bb2be0c0636534be55a170b34dd8386ef5f Mon Sep 17 00:00:00 2001
From: Wilko Meyer <[email-masked]>
Date: Mon, 11 Aug 2025 15:34:07 +0200
Subject: [PATCH] display-time-mode: Include world-clock time in mode line.

* lisp/time.el (display-time-include-world-clock): Add user option.
(display-time-string-forms): Conditionally include world clock time.
---
 lisp/time.el | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lisp/time.el b/lisp/time.el
index 3750206d08e..f6da94d2e9a 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -177,6 +177,11 @@ depend on `display-time-day-and-date' and `display-time-24hr-format'."
   :type '(choice (const :tag "Default" nil)
 		 string))
 
+(defcustom display-time-include-world-clock nil
+  "Non-nil means time from `world-clock-list', `zoneinfo-style-world-list'
+or `legacy-style-world-list' entries are displayed in mode line."
+  :type 'boolean)
+
 (defcustom display-time-string-forms
   '((if (and (not display-time-format) display-time-day-and-date)
 	(format-time-string "%a %b %e " now)
@@ -187,6 +192,18 @@ depend on `display-time-day-and-date' and `display-time-24hr-format'."
 			 now)
      'face 'display-time-date-and-time
      'help-echo (format-time-string "%a %b %e, %Y" now))
+    (if display-time-include-world-clock
+        (mapconcat
+         (lambda (p)
+           (pcase-let ((`(,tz ,label) p))
+             (format " %s (%s)"
+                     (format-time-string
+                      (or display-time-format
+                          (if display-time-24hr-format "%H:%M" "%-I:%M%p"))
+                      now tz)
+                     label)))
+         (time--display-world-list))
+      "")
     load
     (if mail
 	;; Build the string every time to act on customization.
-- 
2.50.1

-- 
Kind regards,
Wilko Meyer