]> code.delx.au - gnu-emacs/blobdiff - lisp/time.el
* xmenu.c: Revert last change.
[gnu-emacs] / lisp / time.el
index a048c9780cbb79b84df05dccc77c8eb3ca74e2ab..8372419da8481d22bf8288344dfafeab1faaf152 100644 (file)
@@ -1,16 +1,16 @@
 ;;; time.el --- display time, load and mail indicator in mode line of Emacs -*-coding: utf-8 -*-
 
 ;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1996, 2000, 2001, 2002,
-;;   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,9 +18,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -132,10 +130,10 @@ LABEL is a string to display as the label of that TIMEZONE's time."
 (defcustom legacy-style-world-list
   '(("PST8PDT" "Seattle")
     ("EST5EDT" "New York")
-    ("BST0BDT" "London")
+    ("GMT0BST" "London")
     ("CET-1CDT" "Paris")
-    ("IST-5:30IDT" "Bangalore")
-    ("JST-9JDT" "Tokyo"))
+    ("IST-5:30" "Bangalore")
+    ("JST-9" "Tokyo"))
   "Alist of traditional-style time zones and places for `display-time-world'.
 Each element has the form (TIMEZONE LABEL).
 TIMEZONE should be a string of the form:
@@ -150,9 +148,17 @@ LABEL is a string to display as the label of that TIMEZONE's time."
   :version "23.1")
 
 (defcustom display-time-world-list
-  (if (memq 'system-type '(gnu/linux ms-dos))
-      zoneinfo-style-world-list
-    legacy-style-world-list)
+  ;; Determine if zoneinfo style timezones are supported by testing that
+  ;; America/New York and Europe/London return different timezones.
+  (let (gmt nyt)
+    (set-time-zone-rule "America/New York")
+    (setq nyt (format-time-string "%z"))
+    (set-time-zone-rule "Europe/London")
+    (setq gmt (format-time-string "%z"))
+    (set-time-zone-rule nil)
+    (if (string-equal nyt gmt)
+        legacy-style-world-list
+      zoneinfo-style-world-list))
   "Alist of time zones and places for `display-time-world' to display.
 Each element has the form (TIMEZONE LABEL).
 TIMEZONE should be in the format supported by `set-time-zone-rule' on
@@ -540,7 +546,33 @@ To turn off the world time display, go to that window and type `q'."
           (when (equal (symbol-name (aref elt 5)) "display-time-world-timer")
             (cancel-timer elt)))))))
 
+;;;###autoload
+(defun emacs-uptime (&optional format)
+  "Return a string giving the uptime of this instance of Emacs.
+FORMAT is a string to format the result, using `format-seconds'.
+For example, the Unix uptime command format is \"%D, %z%2h:%.2m\"."
+  (interactive)
+  (let ((str
+         (format-seconds (or format "%Y, %D, %H, %M, %z%S")
+                         (time-to-seconds
+                          (time-subtract (current-time) before-init-time)))))
+    (if (interactive-p)
+        (message "%s" str)
+      str)))
+
+;;;###autoload
+(defun emacs-init-time ()
+  "Return a string giving the duration of the Emacs initialization."
+  (interactive)
+  (let ((str
+        (format "%.1f seconds"
+                (time-to-seconds
+                 (time-subtract after-init-time before-init-time)))))
+    (if (interactive-p)
+        (message "%s" str)
+      str)))
+
 (provide 'time)
 
-;;; arch-tag: b9c1623f-b5cb-48e4-b650-482a4d23c5a6
+;; arch-tag: b9c1623f-b5cb-48e4-b650-482a4d23c5a6
 ;;; time.el ends here