]> code.delx.au - gnu-emacs/blobdiff - lisp/time.el
(vc-admin): Pass t as noquery arg to vc-resynch-window.
[gnu-emacs] / lisp / time.el
index fe29ca567dfa212f946dec6a27380d9a38b17d0d..8f8385937bc3619af07153f5c913c126f8d15c7c 100644 (file)
@@ -1,11 +1,14 @@
-;; Display time and load in mode line of Emacs.
+;;; time.el --- display time and load in mode line of Emacs.
+
 ;; Copyright (C) 1985, 1986, 1987 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
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 1, or (at your option)
+;; the Free Software Foundation; either version 2, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -17,6 +20,7 @@
 ;; along with GNU Emacs; see the file COPYING.  If not, write to
 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
+;;; Code:
 
 (defvar display-time-mail-file nil
   "*File name of mail inbox file, for indicating existence of new mail.
@@ -31,6 +35,10 @@ Default is system-dependent, and is the same as used by Rmail.")
 (defvar display-time-interval 60
   "*Seconds between updates of time in the mode line.")
 
+(defvar display-time-24hr-format nil
+  "Non-nill indicates time should be displayed as hh:mm, 0 <= hh <= 23.
+Nil means 1 <= hh <= 12, and an AM/PM suffix is used.")
+
 (defvar display-time-string nil)
 
 (defvar display-time-hook nil
@@ -75,7 +83,8 @@ After each update, `display-time-hook' is run with `run-hooks'."
   (let ((time (current-time-string))
        (load (condition-case ()
                  (if (zerop (car (load-average))) ""
-                   (format "%03d" (car (load-average))))
+                   (let ((str (format " %03d" (car (load-average)))))
+                     (concat (substring str 0 -2) "." (substring str -2))))
                (error "")))
        (mail-spool-file (or display-time-mail-file
                             (getenv "MAIL")
@@ -83,17 +92,20 @@ After each update, `display-time-hook' is run with `run-hooks'."
                                     (or (getenv "LOGNAME")
                                         (getenv "USER")
                                         (user-login-name)))))
-       hour pm)
+       hour am-pm-flag)
     (setq hour (read (substring time 11 13)))
-    (setq pm (>= hour 12))
-    (if (> hour 12)
-       (setq hour (- hour 12))
-      (if (= hour 0)
-         (setq hour 12)))
+    (if (not display-time-24hr-format)
+       (progn
+         (setq am-pm-flag (if (>= hour 12) "pm" "am"))
+         (if (> hour 12)
+             (setq hour (- hour 12))
+           (if (= hour 0)
+               (setq hour 12))))
+      (setq am-pm-flag ""))
     (setq display-time-string
          (concat (format "%d" hour) (substring time 13 16)
-                 (if pm "pm " "am ")
-                 (substring load 0 -2) "." (substring load -2)
+                 am-pm-flag
+                 load
                  (if (and (file-exists-p mail-spool-file)
                           ;; file not empty?
                           (display-time-file-nonempty-p mail-spool-file))
@@ -114,3 +126,5 @@ After each update, `display-time-hook' is run with `run-hooks'."
   (while (file-symlink-p file)
     (setq file (file-symlink-p file)))
   (> (nth 7 (file-attributes file)) 0))
+
+;;; time.el ends here