;;; stardate.el --- Calculate and show Stardate from StarTrek ;; -*- mode: emacs-lisp -*- ;; $Id: stardate.el,v 1.5 2003-06-26 14:34:03+09 umq Exp $ ;;; Copyright and licence: ---------------------------------------------------- ;; Copyright (C) 2003 by Hirohisa Yamaguchi ;; ;; This file 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 2, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 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., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Code: (eval-and-compile (require 'time) ) (defgroup stardate nil "Calculate and show Stardate from StarTrek" :group 'data :group 'extensions) (defcustom display-time-stardate t "*Non-nil shows internet time when display-time enabled" :type 'boolean :group 'display-time :require 'time) (defcustom display-time-stardate-only nil "*Non-nil shows internet time only" :type 'boolean :group 'display-time) (defun stardate () "calculate stardate" (interactive) (progn (let ((stardate-time (string-to-int (format-time-string "%s" (current-time))))) (let ((stardate-integer (+ (/ stardate-time 17280) 9350))) (let ((stardate-issue (floor (- (/ stardate-integer 10000) 36))) (stardate-fraction (/ (* (mod stardate-time 17280) 3125) 54)) (stardate-string nil)) (setq stardate-string (concat (format "[%d]" stardate-issue) (format "%04d." (mod stardate-integer 10000)) (substring (format "%06d" stardate-fraction) 0 3))) (if (interactive-p) (princ stardate-string t) stardate-string)))))) (setq display-time-string-forms '((if (and (not display-time-format) display-time-day-and-date) (format-time-string "%a %b %e " now) "") (if display-time-stardate (if display-time-stardate-only (stardate) (concat (format-time-string (or display-time-format (if display-time-24hr-format "%H:%M" "%-I:%M%p")) now) "\(" (stardate) "\)")) (format-time-string (or display-time-format (if display-time-24hr-format "%H:%M" "%-I:%M%p")) now)) load (if mail " Mail" "")) ) (provide 'stardate) ;;; stardate.el ends here