Don't Modify the World


Emacs comes with a few thousand lines of code for calendar calculations. Surely timezone calculations must be a properly solved problem as well! At least, that’s what one would expect given the existence of the very handy M-x display-time-world. Except, it’s not:

(defun display-time-world-display (alist)
  "Replace current buffer text with times in various zones, based on ALIST."
  (let ((inhibit-read-only t)
        (buffer-undo-list t)
        (old-tz (getenv "TZ"))
        (max-width 0)
        result fmt)
        (dolist (zone alist)
          (let* ((label (cadr zone))
                 (width (string-width label)))
            (setenv "TZ" (car zone))
            (push (cons label
                        (format-time-string display-time-world-time-format))
            (when (> width max-width)
              (setq max-width width))))
      (setenv "TZ" old-tz))
    (setq fmt (concat "%-" (int-to-string max-width) "s %s\n"))
    (dolist (timedata (nreverse result))
      (insert (format fmt (car timedata) (cdr timedata))))
    (delete-char -1)))

Tough luck if all you’ve done was customizing Emacs’ current idea of the timezone like wgreenhouse did. Ouch.

edit: Looks like this got fixed properly!