-;; 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,
;; 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.
Default is system-dependent, and is the same as used by Rmail.")
;;;###autoload
-(defconst display-time-day-and-date nil \"
+(defconst display-time-day-and-date nil "\
*Non-nil means \\[display-time] should display day and date as well as time.")
(defvar display-time-process nil)
(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
(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")
(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))
(while (file-symlink-p file)
(setq file (file-symlink-p file)))
(> (nth 7 (file-attributes file)) 0))
+
+;;; time.el ends here