annotate lisp/packages/time-stamp.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents b82b59fe008d
children b9518feda344
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
2 ;;; Copyright 1989, 1993 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Maintainer: Stephen Gildea <gildea@lcs.mit.edu>
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
5 ;; Time-stamp: <93/06/20 17:36:04 gildea>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
8 ;; This file is free software; you can redistribute it and/or modify
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
13 ;; This file is distributed in the hope that it will be useful,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
16 ;; GNU General Public License for more details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
19 ;; along with GNU Emacs; see the file COPYING. If not, write to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
22 ;;; Synched up with: Not synched with FSF.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
26 ;;; If you put a time stamp template anywhere in the first 8 lines of a file,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
27 ;;; it can be updated every time you save the file. See the top of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
28 ;;; time-stamp.el for a sample. The template looks like one of the following:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
29 ;;; Time-stamp: <>
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
30 ;;; Time-stamp: " "
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
31 ;;; The time stamp is written between the brackets or quotes, resulting in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
32 ;;; Time-stamp: <93/06/18 10:26:51 gildea>
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
33 ;;; Here is an example which puts the file name and time stamp in the binary:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
34 ;;; static char *time_stamp = "sdmain.c Time-stamp: <>";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
36 ;;; To activate automatic time stamping, add this code to your .emacs file:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
37 ;;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
38 ;;; (autoload 'time-stamp "time-stamp" "Update the time stamp in a buffer." t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
39 ;;; (if (not (memq 'time-stamp write-file-hooks))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
40 ;;; (setq write-file-hooks
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
41 ;;; (cons 'time-stamp write-file-hooks)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; Change Log:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
45 ;;; Originally based on the 19 Dec 88 version of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
46 ;;; date.el by John Sturdy <mcvax!harlqn.co.uk!jcgs@uunet.uu.net>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defvar time-stamp-active t
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
51 "*Non-nil to enable time-stamping of files. See the function time-stamp.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
53 (defvar time-stamp-format
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
54 '(time-stamp-yy/mm/dd time-stamp-hh:mm:ss user-login-name)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
55 "*A list of functions to call to generate the time stamp string.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
56 Each element of the list is called as a function and the results are
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
57 concatenated together separated by spaces. Elements may also be strings,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
58 which are included verbatim. Spaces are not inserted around literal strings.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; Do not change time-stamp-line-limit, time-stamp-start, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; time-stamp-end in your .emacs or you will be incompatible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; with other people's files! If you must change them,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; do so only in the local variables section of the file itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
65 (defvar time-stamp-line-limit 8 ;Do not change! See comment above.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
66 "Number of lines at the beginning of a file that are searched.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
67 The patterns time-stamp-start and time-stamp-end must be found on one
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
68 of the first time-stamp-line-limit lines of the file for the file to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
69 be time-stamped.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
71 (defvar time-stamp-start "Time-stamp: \\\\?[\"<]+" ;Do not change!
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
72 "Regexp after which the time stamp is written by \\[time-stamp].
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
73 See also the variables time-stamp-end and time-stamp-line-limit.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
74
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
75 Do not change time-stamp-line-limit, time-stamp-start, or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
76 time-stamp-end for yourself or you will be incompatible
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 with other people's files! If you must change them for some application,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 do so in the local variables section of the time-stamped file itself.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
81 (defvar time-stamp-end "\\\\?[\">]" ;Do not change! See comment above.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 "Regexp marking the text after the time stamp.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
83 \\[time-stamp] deletes the text between the first match of time-stamp-start
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
84 \(which see) and the following match of time-stamp-end on the same line,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
85 then writes the time stamp specified by time-stamp-format between them.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defun time-stamp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "Update the time stamp string in the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 Only does its thing if the variable time-stamp-active is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 Typically used on write-file-hooks for automatic time-stamping.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
92 The format of the time stamp is determined by the variable
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
93 time-stamp-format. The first time-stamp-line-limit lines of the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
94 buffer (normally 8) are searched for the time stamp template,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
95 and if it is found, a new time stamp is written into it."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
97 (if time-stamp-active
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
98 (let ((case-fold-search nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
99 (if (and (stringp time-stamp-start)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
100 (stringp time-stamp-end))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
101 (save-excursion
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
102 (goto-char (point-min))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
103 (if (re-search-forward time-stamp-start
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
104 (save-excursion
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
105 (forward-line time-stamp-line-limit)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
106 (point))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
107 t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
108 (let ((start (point)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
109 (if (re-search-forward time-stamp-end
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
110 (save-excursion (end-of-line) (point))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
111 t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
112 (let ((end (match-beginning 0)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
113 (delete-region start end)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
114 (goto-char start)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
115 (insert (time-stamp-string))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
116 (setq end (point))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
117 ;; remove any tabs used to format the time stamp
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
118 (goto-char start)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
119 (if (search-forward "\t" end t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
120 (untabify start end)))))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
121 ;; don't signal an error in a write-file-hook
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
122 (message "time-stamp-start or time-stamp-end is not a string"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; be sure to return nil so can be used on write-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (defun time-stamp-string ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 "Generate the new string to be inserted by \\[time-stamp]."
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
128 (time-stamp-fconcat time-stamp-format " "))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defun time-stamp-fconcat (list sep)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
131 "Similar to (mapconcat 'funcall LIST SEP) but LIST can have literals.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 If an element of LIST is a symbol, it is funcalled to get the string to use;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 the separator SEP is used between two strings obtained by funcalling a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 symbol. Otherwise the element itself is inserted; no separator is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 around literals."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (let ((return-string "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (insert-sep-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (cond ((symbolp (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (if insert-sep-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (setq return-string (concat return-string sep)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (setq return-string (concat return-string (funcall (car list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (setq insert-sep-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq return-string (concat return-string (car list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (setq insert-sep-p nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setq list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 return-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
151 (defconst time-stamp-month-numbers
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
152 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) ("May" . 5) ("Jun" . 6)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
153 ("Jul" . 7) ("Aug" . 8) ("Sep" . 9) ("Oct" . 10) ("Nov" . 11) ("Dec" . 12))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
154 "Assoc list of months and their number.")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
155
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
156 (defconst time-stamp-month-full-names
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
157 ["(zero)" "January" "February" "March" "April" "May" "June"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
158 "July" "August" "September" "October" "November" "December"])
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
159
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
160 (defvar time-stamp-mail-host nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
161 "Name of the host where the user receives mail.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
162 See the function time-stamp-mail-host-name.")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
163
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;; Some useful functions to use in time-stamp-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;;; Could generate most of a message-id with
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
167 ;;; '(yymmdd "" hhmm "@" mail-host-name)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
168
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
169 (defun time-stamp-mail-host-name ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
170 "Return the name of the host where the user receives mail.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
171 This is the value of time-stamp-mail-host if bound and a string,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
172 otherwise the value of the function system-name."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
173 (or (and (boundp 'time-stamp-mail-host)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
174 (stringp time-stamp-mail-host)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
175 time-stamp-mail-host)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
176 (system-name)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
177
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
178 (defun time-stamp-current-year ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
179 "Return the current year as a four-character string."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
180 (substring (current-time-string) -4))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;; pretty form, suitable for a title page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (defun time-stamp-month-dd-yyyy ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
185 "Return the current date as a string in \"Month dd, yyyy\" form."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (let ((date (current-time-string)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
187 (format "%s %02d, %s"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (aref time-stamp-month-full-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (cdr (assoc (substring date 4 7) time-stamp-month-numbers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (string-to-int (substring date 8 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (substring date -4))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;; same as __DATE__ in ANSI C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defun time-stamp-mon-dd-yyyy ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
196 "Return the current date as a string in \"Mon dd yyyy\" form.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
197 The first character of dd is Space if the value is less than 10."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (let ((date (current-time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (format "%s %2d %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (substring date 4 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (string-to-int (substring date 8 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (substring date -4))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;; RFC 822 date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (defun time-stamp-dd-mon-yy ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
207 "Return the current date as a string in \"dd Mon yy\" form."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (let ((date (current-time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (format "%02d %s %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (string-to-int (substring date 8 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (substring date 4 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (substring date -2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;; RCS 3 date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defun time-stamp-yy/mm/dd ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
217 "Return the current date as a string in \"yy/mm/dd\" form."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (let ((date (current-time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (format "%s/%02d/%02d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (substring date -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (string-to-int (substring date 8 10)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;;; RCS 5 date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defun time-stamp-yyyy/mm/dd ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
227 "Return the current date as a string in \"yyyy/mm/dd\" form."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (let ((date (current-time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (format "%s/%02d/%02d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (substring date -4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (string-to-int (substring date 8 10)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (defun time-stamp-yymmdd ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
235 "Return the current date as a string in \"yymmdd\" form."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (let ((date (current-time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (format "%s%02d%02d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (substring date -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (string-to-int (substring date 8 10)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
242 (defun time-stamp-dd/mm/yy ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
243 "Return the current date as a string in \"dd/mm/yy\" form."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
244 (let ((date (current-time-string)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
245 (format "%02d/%02d/%s"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
246 (string-to-int (substring date 8 10))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
247 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
248 (substring date -2))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
249
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
250 (defun time-stamp-mm/dd/yy ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
251 "Return the current date as a string in \"mm/dd/yy\" form."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
252 (let ((date (current-time-string)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
253 (format "%02d/%02d/%s"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
254 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
255 (string-to-int (substring date 8 10))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
256 (substring date -2))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
257
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defun time-stamp-hh:mm:ss ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
259 "Return the current time as a string in \"hh:mm:ss\" form."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (substring (current-time-string) 11 19))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
262 (defun time-stamp-hh:mm ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
263 "Return the current time as a string in \"hh:mm\" form."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
264 (substring (current-time-string) 11 16))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
265
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (defun time-stamp-hhmm ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
267 "Return the current time as a string in \"hhmm\" form."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (let ((date (current-time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (concat (substring date 11 13)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (substring date 14 16))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (provide 'time-stamp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;;; time-stamp.el ends here