diff options
Diffstat (limited to 'lisp/time.el')
| -rw-r--r-- | lisp/time.el | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/lisp/time.el b/lisp/time.el index b158ef64691..f8fea0c64a2 100644 --- a/lisp/time.el +++ b/lisp/time.el | |||
| @@ -156,21 +156,24 @@ LABEL is a string to display as the label of that TIMEZONE's time." | |||
| 156 | (defcustom display-time-world-list | 156 | (defcustom display-time-world-list |
| 157 | ;; Determine if zoneinfo style timezones are supported by testing that | 157 | ;; Determine if zoneinfo style timezones are supported by testing that |
| 158 | ;; America/New York and Europe/London return different timezones. | 158 | ;; America/New York and Europe/London return different timezones. |
| 159 | (let (gmt nyt) | 159 | (let ((old-tz (getenv "TZ")) |
| 160 | (set-time-zone-rule "America/New_York") | 160 | gmt nyt) |
| 161 | (setq nyt (format-time-string "%z")) | 161 | (unwind-protect |
| 162 | (set-time-zone-rule "Europe/London") | 162 | (progn |
| 163 | (setq gmt (format-time-string "%z")) | 163 | (setenv "TZ" "America/New_York") |
| 164 | (set-time-zone-rule nil) | 164 | (setq nyt (format-time-string "%z")) |
| 165 | (setenv "TZ" "Europe/London") | ||
| 166 | (setq gmt (format-time-string "%z"))) | ||
| 167 | (setenv "TZ" old-tz)) | ||
| 165 | (if (string-equal nyt gmt) | 168 | (if (string-equal nyt gmt) |
| 166 | legacy-style-world-list | 169 | legacy-style-world-list |
| 167 | zoneinfo-style-world-list)) | 170 | zoneinfo-style-world-list)) |
| 168 | "Alist of time zones and places for `display-time-world' to display. | 171 | "Alist of time zones and places for `display-time-world' to display. |
| 169 | Each element has the form (TIMEZONE LABEL). | 172 | Each element has the form (TIMEZONE LABEL). |
| 170 | TIMEZONE should be in the format supported by `set-time-zone-rule' on | 173 | TIMEZONE should be in a format supported by your system. See the |
| 171 | your system. See the documentation of `zoneinfo-style-world-list' and | 174 | documentation of `zoneinfo-style-world-list' and |
| 172 | \`legacy-style-world-list' for two widely used formats. | 175 | \`legacy-style-world-list' for two widely used formats. LABEL is |
| 173 | LABEL is a string to display as the label of that TIMEZONE's time." | 176 | a string to display as the label of that TIMEZONE's time." |
| 174 | :group 'display-time | 177 | :group 'display-time |
| 175 | :type '(repeat (list string string)) | 178 | :type '(repeat (list string string)) |
| 176 | :version "23.1") | 179 | :version "23.1") |
| @@ -521,26 +524,26 @@ See `display-time-world'." | |||
| 521 | (defun display-time-world-display (alist) | 524 | (defun display-time-world-display (alist) |
| 522 | "Replace current buffer text with times in various zones, based on ALIST." | 525 | "Replace current buffer text with times in various zones, based on ALIST." |
| 523 | (let ((inhibit-read-only t) | 526 | (let ((inhibit-read-only t) |
| 524 | (buffer-undo-list t)) | 527 | (buffer-undo-list t) |
| 528 | (old-tz (getenv "TZ")) | ||
| 529 | (max-width 0) | ||
| 530 | result fmt) | ||
| 525 | (erase-buffer) | 531 | (erase-buffer) |
| 526 | (let ((max-width 0) | 532 | (unwind-protect |
| 527 | (result ()) | 533 | (dolist (zone alist) |
| 528 | fmt) | 534 | (let* ((label (cadr zone)) |
| 529 | (unwind-protect | 535 | (width (string-width label))) |
| 530 | (dolist (zone alist) | 536 | (setenv "TZ" (car zone)) |
| 531 | (let* ((label (cadr zone)) | 537 | (push (cons label |
| 532 | (width (string-width label))) | 538 | (format-time-string display-time-world-time-format)) |
| 533 | (set-time-zone-rule (car zone)) | 539 | result) |
| 534 | (push (cons label | 540 | (when (> width max-width) |
| 535 | (format-time-string display-time-world-time-format)) | 541 | (setq max-width width)))) |
| 536 | result) | 542 | (setenv "TZ" old-tz)) |
| 537 | (when (> width max-width) | 543 | (setq fmt (concat "%-" (int-to-string max-width) "s %s\n")) |
| 538 | (setq max-width width)))) | 544 | (dolist (timedata (nreverse result)) |
| 539 | (set-time-zone-rule nil)) | 545 | (insert (format fmt (car timedata) (cdr timedata))))) |
| 540 | (setq fmt (concat "%-" (int-to-string max-width) "s %s\n")) | 546 | (delete-char -1)) |
| 541 | (dolist (timedata (nreverse result)) | ||
| 542 | (insert (format fmt (car timedata) (cdr timedata))))) | ||
| 543 | (delete-char -1))) | ||
| 544 | 547 | ||
| 545 | ;;;###autoload | 548 | ;;;###autoload |
| 546 | (defun display-time-world () | 549 | (defun display-time-world () |