(install): Use INSTALL_STRIP with INSTALL_PROGRAM for the utilities.
[bpt/emacs.git] / lisp / time-stamp.el
CommitLineData
9565745a 1;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs
9565745a 2
fd72ddf6 3;; Copyright 1989, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
b578f267 4
95772e85 5;; Maintainer's Time-stamp: <1997-08-07 14:46:50 gildea>
622b7ede 6;; Maintainer: Stephen Gildea <gildea@alum.mit.edu>
9565745a
RS
7;; Keywords: tools
8
9;; This file is free software; you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation; either version 2, or (at your option)
12;; any later version.
13
14;; This file is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
b578f267
EN
20;; along with GNU Emacs; see the file COPYING. If not, write to the
21;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22;; Boston, MA 02111-1307, USA.
9565745a
RS
23
24;;; Commentary:
25
03d7856a
KH
26;; A template in a file can be updated with a new time stamp when
27;; you save the file. For example:
28;; static char *ts = "sdmain.c Time-stamp: <1996-08-13 10:20:51 gildea>";
29;; See the top of `time-stamp.el' for another example.
30
31;; To use time-stamping, add this line to your .emacs file:
32;; (add-hook 'write-file-hooks 'time-stamp)
33;; Now any time-stamp templates in your files will be updated automatically.
34
35;; See the documentation for the functions `time-stamp'
36;; and `time-stamp-toggle-active' for details.
b578f267 37
9565745a
RS
38;;; Code:
39
cb35a83c
RS
40(defgroup time-stamp nil
41 "Maintain last change time stamps in files edited by Emacs."
42 :group 'data
43 :group 'extensions)
44
fd72ddf6 45(defcustom time-stamp-format "%:y-%02m-%02d %02H:%02M:%02S %u"
03d7856a 46 "*Format of the string inserted by \\[time-stamp].
c9c0e4bb
RS
47The value may be a string or a list. Lists are supported only for
48backward compatibility; see variable `time-stamp-old-format-warn'.
f8d35bf3 49
fd72ddf6
RS
50A string is used verbatim except for character sequences beginning with %:
51
52%:a weekday name: `Monday'. %#A gives uppercase: `MONDAY'
53%3a abbreviated weekday: `Mon'. %3A gives uppercase: `MON'
54%:b month name: `January'. %#B gives uppercase: `JANUARY'
55%3b abbreviated month: `Jan'. %3B gives uppercase: `JAN'
56%02d day of month
57%02H 24-hour clock hour
58%02I 12-hour clock hour
59%02m month number
60%02M minute
61%#p `am' or `pm'. %P gives uppercase: `AM' or `PM'
62%02S seconds
63%w day number of week, Sunday is 0
64%02y 2-digit year: `97' %:y 4-digit year: `1997'
65%z time zone name: `est'. %Z gives uppercase: `EST'
66
67Non-date items:
68%% a literal percent character: `%'
69%f file name without directory %F gives absolute pathname
70%s system name
71%u user's login name
72%h mail host name
73
74Decimal digits between the % and the type character specify the
75field width. Strings are truncated on the right; years on the left.
76A leading zero causes numbers to be zero-filled.
622b7ede
RS
77
78For example, to get the format used by the `date' command,
fd72ddf6
RS
79use \"%3a %3b %2d %02H:%02M:%02S %Z %:y\".
80
81In the future these formats will be aligned more with format-time-string.
82Because of this transition, the default padding for numeric formats will
83change in a future version. Therefore either a padding width should be
84specified, or the : modifier should be used to explicitly request the
85historical default."
cb35a83c
RS
86 :type 'string
87 :group 'time-stamp)
03d7856a 88
95772e85
RS
89(defcustom time-stamp-active t
90 "*Non-nil to enable time-stamping of buffers by \\[time-stamp].
91Can be toggled by \\[time-stamp-toggle-active].
92See also the variable `time-stamp-warn-inactive'."
93 :type 'boolean
94 :group 'time-stamp)
95
96(defcustom time-stamp-warn-inactive t
97 "Non-nil to have \\[time-stamp] warn if a buffer did not get time-stamped.
98A warning is printed if `time-stamp-active' is nil and the buffer contains
99a time stamp template that would otherwise have been updated."
100 :type 'boolean
101 :group 'time-stamp)
102
103(defcustom time-stamp-old-format-warn 'ask
104 "Action to take if `time-stamp-format' is an old-style list.
105If `error', the format is not used. If `ask', the user is queried about
106using the time-stamp-format. If `warn', a warning is displayed.
107If nil, no notification is given."
108 :type '(choice (const :tag "No notification" nil)
109 (const :tag "Don't use the format" error)
110 (const ask) (const warn))
111 :group 'time-stamp)
112
113(defcustom time-stamp-time-zone nil
114 "If non-nil, a string naming the timezone to be used by \\[time-stamp].
115Format is the same as that used by the environment variable TZ on your system."
7967f8ab 116 :type '(choice (const nil) string)
95772e85 117 :group 'time-stamp)
622b7ede
RS
118
119
9565745a
RS
120;;; Do not change time-stamp-line-limit, time-stamp-start, or
121;;; time-stamp-end in your .emacs or you will be incompatible
122;;; with other people's files! If you must change them,
123;;; do so only in the local variables section of the file itself.
124
03d7856a 125
e1f40b28 126(defvar time-stamp-line-limit 8 ;Do not change!
c7c4ddd4 127 "Lines of a file searched; positive counts from start, negative from end.
e1f40b28 128The patterns `time-stamp-start' and `time-stamp-end' must be found on one
c7c4ddd4
KH
129of the first (last) `time-stamp-line-limit' lines of the file for the
130file to be time-stamped by \\[time-stamp].
e1f40b28
RS
131
132Do not change `time-stamp-line-limit', `time-stamp-start', or
133`time-stamp-end' for yourself or you will be incompatible
134with other people's files! If you must change them for some application,
135do so in the local variables section of the time-stamped file itself.")
136
9565745a 137
36081614 138(defvar time-stamp-start "Time-stamp:[ \t]+\\\\?[\"<]+" ;Do not change!
9565745a 139 "Regexp after which the time stamp is written by \\[time-stamp].
e1f40b28 140See also the variables `time-stamp-end' and `time-stamp-line-limit'.
9565745a 141
e1f40b28
RS
142Do not change `time-stamp-line-limit', `time-stamp-start', or
143`time-stamp-end' for yourself or you will be incompatible
9565745a
RS
144with other people's files! If you must change them for some application,
145do so in the local variables section of the time-stamped file itself.")
146
147
e1f40b28 148(defvar time-stamp-end "\\\\?[\">]" ;Do not change!
9565745a 149 "Regexp marking the text after the time stamp.
e1f40b28
RS
150\\[time-stamp] deletes the text between the first match of `time-stamp-start'
151and the following match of `time-stamp-end' on the same line,
152then writes the time stamp specified by `time-stamp-format' between them.
153
154Do not change `time-stamp-line-limit', `time-stamp-start', or
155`time-stamp-end' for yourself or you will be incompatible
156with other people's files! If you must change them for some application,
157do so in the local variables section of the time-stamped file itself.")
158
9565745a 159
03d7856a 160
59b644e8 161;;;###autoload
9565745a
RS
162(defun time-stamp ()
163 "Update the time stamp string in the buffer.
03d7856a
KH
164A template in a file can be automatically updated with a new time stamp
165every time you save the file. Add this line to your .emacs file:
166 (add-hook 'write-file-hooks 'time-stamp)
167Normally the template must appear in the first 8 lines of a file and
168look like one of the following:
169 Time-stamp: <>
170 Time-stamp: \" \"
171The time stamp is written between the brackets or quotes:
172 Time-stamp: <1996-07-18 10:20:51 gildea>
622b7ede 173The time stamp is updated only if the variable `time-stamp-active' is non-nil.
03d7856a
KH
174The format of the time stamp is set by the variable `time-stamp-format'.
175The variables `time-stamp-line-limit', `time-stamp-start',
176and `time-stamp-end' control finding the template."
9565745a 177 (interactive)
fe8287c6 178 (let ((case-fold-search nil)
03d7856a
KH
179 (start nil)
180 (end nil)
622b7ede
RS
181 search-limit
182 (line-limit time-stamp-line-limit))
183 (cond ((not (integerp line-limit))
184 (setq line-limit 8)
185 (message "time-stamp-line-limit is not a number")
186 (sit-for 1)))
187 (save-excursion
188 (save-restriction
189 (widen)
190 (cond ((> line-limit 0)
191 (goto-char (setq start (point-min)))
192 (forward-line line-limit)
193 (setq search-limit (point)))
194 (t
195 (goto-char (setq search-limit (point-max)))
196 (forward-line line-limit)
197 (setq start (point))))
198 (goto-char start)
199 (while (and (< (point) search-limit)
200 (not end)
201 (re-search-forward time-stamp-start search-limit 'move))
202 (setq start (point))
203 (end-of-line)
204 (let ((line-end (point)))
c7c4ddd4 205 (goto-char start)
622b7ede
RS
206 (if (re-search-forward time-stamp-end line-end 'move)
207 (setq end (match-beginning 0)))))))
03d7856a
KH
208 (if end
209 (progn
210 ;; do all warnings outside save-excursion
211 (cond
212 ((not time-stamp-active)
213 (if time-stamp-warn-inactive
214 ;; don't signal an error in a write-file-hook
c7c4ddd4 215 (progn
03d7856a
KH
216 (message "Warning: time-stamp-active is off; did not time-stamp buffer.")
217 (sit-for 1))))
218 ((not (and (stringp time-stamp-start)
219 (stringp time-stamp-end)))
220 (message "time-stamp-start or time-stamp-end is not a string")
221 (sit-for 1))
222 (t
223 (let ((new-time-stamp (time-stamp-string)))
224 (if (stringp new-time-stamp)
225 (save-excursion
226 (save-restriction
227 (widen)
228 (delete-region start end)
229 (goto-char start)
68869701 230 (insert-and-inherit new-time-stamp)
03d7856a
KH
231 (setq end (point))
232 ;; remove any tabs used to format time stamp
233 (goto-char start)
234 (if (search-forward "\t" end t)
235 (untabify start end)))))))))))
9565745a
RS
236 ;; be sure to return nil so can be used on write-file-hooks
237 nil)
238
b1defad2
RS
239;;;###autoload
240(defun time-stamp-toggle-active (&optional arg)
03d7856a 241 "Toggle `time-stamp-active', setting whether \\[time-stamp] updates a buffer.
b1defad2
RS
242With arg, turn time stamping on if and only if arg is positive."
243 (interactive "P")
244 (setq time-stamp-active
245 (if (null arg)
246 (not time-stamp-active)
247 (> (prefix-numeric-value arg) 0)))
248 (message "time-stamp is now %s." (if time-stamp-active "active" "off")))
03d7856a 249
6946129c
RS
250(defconst time-stamp-no-file "(no file)"
251 "String to use when the buffer is not associated with a file.")
252
fd72ddf6
RS
253;;; time-stamp is transitioning to using the new, expanded capabilities
254;;; of format-time-string. During the process, this function implements
255;;; intermediate, compatible formats and complains about old, soon to
256;;; be unsupported, formats. This function will get a lot (a LOT) shorter
257;;; when the transition is complete and we can just pass most things
258;;; straight through to format-time-string.
259;;; At all times, all the formats recommended in the doc string
260;;; of time-stamp-format will work not only in the current version of
261;;; Emacs, but in all versions that have been released within the past
262;;; two years.
263;;; The : modifier is a temporary conversion feature used to resolve
264;;; ambiguous formats--formats that are changing (over time) incompatibly.
265(defun time-stamp-string-preprocess (format &optional time)
266 ;; Uses a FORMAT to format date, time, file, and user information.
267 ;; Optional second argument TIME is only for testing.
268 ;; Implements non-time extensions to format-time-string
269 ;; and all time-stamp-format compatibility.
270 (let ((fmt-len (length format))
271 (ind 0)
272 cur-char
273 (prev-char nil)
274 (result "")
275 field-index
276 field-width
277 field-result
278 alt-form change-case require-padding
279 (paren-level 0))
280 (while (< ind fmt-len)
281 (setq cur-char (aref format ind))
282 (setq
283 result
284 (concat result
285 (cond
286 ((eq cur-char ?%)
287 ;; eat any additional args to allow for future expansion
288 (setq alt-form nil change-case nil require-padding nil)
289 (while (progn
290 (setq ind (1+ ind))
291 (setq cur-char (if (< ind fmt-len)
292 (aref format ind)
293 ?\0))
294 (or (eq ?. cur-char)
295 (eq ?, cur-char) (eq ?: cur-char) (eq ?@ cur-char)
296 (eq ?- cur-char) (eq ?+ cur-char) (eq ?_ cur-char)
297 (eq ?\ cur-char) (eq ?# cur-char) (eq ?^ cur-char)
298 (and (eq ?\( cur-char)
299 (not (eq prev-char ?\\))
300 (setq paren-level (1+ paren-level)))
301 (if (and (eq ?\) cur-char)
302 (not (eq prev-char ?\\))
303 (> paren-level 0))
304 (setq paren-level (1- paren-level))
305 (and (> paren-level 0)
306 (< ind fmt-len)))))
307 (setq prev-char cur-char)
308 ;; some characters we actually use
309 (cond ((eq cur-char ?:)
310 (setq alt-form t))
311 ((eq cur-char ?#)
312 (setq change-case t))))
313 ;; get format width
314 (setq field-index ind)
315 (setq ind (1- ind))
316 (while (progn
317 (setq ind (1+ ind))
318 (setq cur-char (if (< ind fmt-len)
319 (aref format ind)
320 ?\0))
321 (and (<= ?0 cur-char) (>= ?9 cur-char))))
322 (setq field-width (substring format field-index ind))
323 (setq field-result
324 (cond
325 ((eq cur-char ?%)
326 "%")
327 ((eq cur-char ?a) ;day of week
328 (if change-case
329 (format-time-string "%#A" time)
330 (or alt-form (not (string-equal field-width ""))
331 (time-stamp-conv-warn "%a" "%:a"))
332 (if (and alt-form (not (string-equal field-width "")))
333 "" ;discourage "%:3a"
334 (format-time-string "%A" time))))
335 ((eq cur-char ?A)
336 (if alt-form
337 (format-time-string "%A" time)
338 (or change-case (not (string-equal field-width ""))
339 (time-stamp-conv-warn "%A" "%#A"))
340 (format-time-string "%#A" time)))
341 ((eq cur-char ?b) ;month name
342 (if change-case
343 (format-time-string "%#B" time)
344 (or alt-form (not (string-equal field-width ""))
345 (time-stamp-conv-warn "%b" "%:b"))
346 (if (and alt-form (not (string-equal field-width "")))
347 "" ;discourage "%:3b"
348 (format-time-string "%B" time))))
349 ((eq cur-char ?B)
350 (if alt-form
351 (format-time-string "%B" time)
352 (or change-case (not (string-equal field-width ""))
353 (time-stamp-conv-warn "%B" "%#B"))
354 (format-time-string "%#B" time)))
355 ((eq cur-char ?d) ;day of month, 1-31
fdac7fba 356 (time-stamp-do-number cur-char alt-form field-width time))
fd72ddf6 357 ((eq cur-char ?H) ;hour, 0-23
fdac7fba 358 (time-stamp-do-number cur-char alt-form field-width time))
fd72ddf6 359 ((eq cur-char ?I) ;hour, 1-12
fdac7fba 360 (time-stamp-do-number cur-char alt-form field-width time))
fd72ddf6 361 ((eq cur-char ?m) ;month number, 1-12
fdac7fba 362 (time-stamp-do-number cur-char alt-form field-width time))
fd72ddf6 363 ((eq cur-char ?M) ;minute, 0-59
fdac7fba 364 (time-stamp-do-number cur-char alt-form field-width time))
fd72ddf6
RS
365 ((eq cur-char ?p) ;am or pm
366 (or change-case
367 (time-stamp-conv-warn "%p" "%#p"))
368 (format-time-string "%#p" time))
369 ((eq cur-char ?P) ;AM or PM
370 (format-time-string "%p" time))
371 ((eq cur-char ?S) ;seconds, 00-60
fdac7fba 372 (time-stamp-do-number cur-char alt-form field-width time))
fd72ddf6
RS
373 ((eq cur-char ?w) ;weekday number, Sunday is 0
374 (format-time-string "%w" time))
375 ((eq cur-char ?y) ;year
376 (or alt-form (not (string-equal field-width ""))
377 (time-stamp-conv-warn "%y" "%:y"))
378 (string-to-int (format-time-string "%Y" time)))
379 ((eq cur-char ?Y) ;4-digit year, new style
380 (string-to-int (format-time-string "%Y" time)))
381 ((eq cur-char ?z) ;time zone lower case
382 (if change-case
383 "" ;discourage %z variations
384 (format-time-string "%#Z" time)))
385 ((eq cur-char ?Z)
386 (if change-case
387 (format-time-string "%#Z" time)
388 (format-time-string "%Z" time)))
389 ((eq cur-char ?f) ;buffer-file-name, base name only
390 (if buffer-file-name
391 (file-name-nondirectory buffer-file-name)
392 time-stamp-no-file))
393 ((eq cur-char ?F) ;buffer-file-name, full path
394 (or buffer-file-name
395 time-stamp-no-file))
396 ((eq cur-char ?s) ;system name
397 (system-name))
398 ((eq cur-char ?u) ;user name
399 (user-login-name))
400 ((eq cur-char ?h) ;mail host name
401 (time-stamp-mail-host-name))
402 ))
403 (if (string-equal field-width "")
404 field-result
405 (let ((padded-result
406 (format (format "%%%s%c"
407 field-width
408 (if (numberp field-result) ?d ?s))
409 (or field-result ""))))
410 (let ((initial-length (length padded-result))
411 (desired-length (string-to-int field-width)))
412 (if (> initial-length desired-length)
413 ;; truncate strings on right, years on left
414 (if (stringp field-result)
415 (substring padded-result 0 desired-length)
416 (if (eq cur-char ?y)
417 (substring padded-result (- desired-length))
418 padded-result)) ;non-year numbers don't truncate
419 padded-result)))))
420 (t
421 (char-to-string cur-char)))))
422 (setq ind (1+ ind)))
423 result))
424
fdac7fba
RS
425(defun time-stamp-do-number (format-char alt-form field-width time)
426 ;; Handle a compatible FORMAT-CHAR where only
fd72ddf6 427 ;; the default width/padding will change.
fdac7fba
RS
428 ;; ALT-FORM is whether `#' specified. FIELD-WIDTH is the string
429 ;; width specification or "". TIME is the time to convert.
fd72ddf6
RS
430 (let ((format-string (concat "%" (char-to-string format-char))))
431 (and (not alt-form) (string-equal field-width "")
432 (time-stamp-conv-warn format-string
433 (format "%%:%c" format-char)))
434 (if (and alt-form (not (string-equal field-width "")))
435 "" ;discourage "%:2d" and the like
436 (string-to-int (format-time-string format-string time)))))
437
438(defvar time-stamp-conversion-warn t
439 "Non-nil to warn about soon-to-be-unsupported forms in time-stamp-format.
440In would be a bad idea to disable these warnings!
441You really need to update your files instead.
442
443The new formats will work with old versions of Emacs.
444New formats are being recommended now to allow time-stamp-format
445to change in the future to be compatible with format-time-string.
446The new forms being recommended now will continue to work then.")
447
448
449(defun time-stamp-conv-warn (old-form new-form)
450 ;; Display a warning about a soon-to-be-obsolete format.
451 (cond
452 (time-stamp-conversion-warn
453 (save-excursion
454 (set-buffer (get-buffer-create "*Time-stamp-compatibility*"))
455 (goto-char (point-max))
456 (if (bobp)
457 (progn
458 (insert
459 "The formats recognized in time-stamp-format will change in a future release\n"
460 "to be compatible with the new, expanded format-time-string function.\n\n"
461 "The following obsolescent time-stamp-format construct(s) were found:\n\n")))
462 (insert "\"" old-form "\" -- use " new-form "\n"))
463 (display-buffer "*Time-stamp-compatibility*"))))
95772e85 464
fd72ddf6 465
b1defad2 466
9565745a
RS
467(defun time-stamp-string ()
468 "Generate the new string to be inserted by \\[time-stamp]."
b1defad2 469 (if (stringp time-stamp-format)
95772e85
RS
470 (if (stringp time-stamp-time-zone)
471 (let ((real-time-zone (getenv "TZ")))
472 (unwind-protect
473 (progn
474 (setenv "TZ" time-stamp-time-zone)
475 (format-time-string
476 (time-stamp-string-preprocess time-stamp-format)))
477 (setenv "TZ" real-time-zone)))
478 (format-time-string
479 (time-stamp-string-preprocess time-stamp-format)))
03d7856a
KH
480 ;; handle version 1 compatibility
481 (cond ((or (eq time-stamp-old-format-warn 'error)
482 (and (eq time-stamp-old-format-warn 'ask)
483 (not (y-or-n-p "Use non-string time-stamp-format? "))))
484 (message "Warning: no time-stamp: time-stamp-format not a string")
485 (sit-for 1)
486 nil)
487 (t
488 (cond ((eq time-stamp-old-format-warn 'warn)
489 (message "Obsolescent time-stamp-format type; should be string")
490 (sit-for 1)))
491 (time-stamp-fconcat time-stamp-format " ")))))
b1defad2 492
c7c4ddd4
KH
493(defconst time-stamp-no-file "(no file)"
494 "String to use when the buffer is not associated with a file.")
495
b1defad2
RS
496(defun time-stamp-mail-host-name ()
497 "Return the name of the host where the user receives mail.
498This is the value of `mail-host-address' if bound and a string,
e654f4b0 499otherwise the value of the function system-name."
b1defad2
RS
500 (or (and (boundp 'mail-host-address)
501 (stringp mail-host-address)
502 mail-host-address)
b1defad2
RS
503 (system-name)))
504
505;;; the rest of this file is for version 1 compatibility
9565745a
RS
506
507(defun time-stamp-fconcat (list sep)
e1f40b28 508 "Similar to (mapconcat 'funcall LIST SEP) but LIST allows literals.
9565745a
RS
509If an element of LIST is a symbol, it is funcalled to get the string to use;
510the separator SEP is used between two strings obtained by funcalling a
511symbol. Otherwise the element itself is inserted; no separator is used
512around literals."
513 (let ((return-string "")
514 (insert-sep-p nil))
515 (while list
516 (cond ((symbolp (car list))
517 (if insert-sep-p
518 (setq return-string (concat return-string sep)))
519 (setq return-string (concat return-string (funcall (car list))))
520 (setq insert-sep-p t))
521 (t
522 (setq return-string (concat return-string (car list)))
523 (setq insert-sep-p nil)))
524 (setq list (cdr list)))
525 return-string))
526
03d7856a 527;;; Some functions used in time-stamp-format
9565745a
RS
528
529;;; Could generate most of a message-id with
e1f40b28 530;;; '(time-stamp-yymmdd "" time-stamp-hhmm "@" time-stamp-mail-host-name)
9565745a 531
9565745a
RS
532;;; pretty form, suitable for a title page
533
534(defun time-stamp-month-dd-yyyy ()
e1f40b28 535 "Return the current date as a string in \"Month DD, YYYY\" form."
b8944601 536 (format-time-string "%B %e, %Y"))
9565745a 537
b24173f7
RS
538(defun time-stamp-dd/mm/yyyy ()
539 "Return the current date as a string in \"DD/MM/YYYY\" form."
b8944601 540 (format-time-string "%d/%m/%Y"))
b24173f7 541
9565745a
RS
542;;; same as __DATE__ in ANSI C
543
544(defun time-stamp-mon-dd-yyyy ()
e1f40b28
RS
545 "Return the current date as a string in \"Mon DD YYYY\" form.
546The first character of DD is space if the value is less than 10."
b8944601 547 (format-time-string "%b %d %Y"))
9565745a
RS
548
549;;; RFC 822 date
550
551(defun time-stamp-dd-mon-yy ()
e1f40b28 552 "Return the current date as a string in \"DD Mon YY\" form."
b8944601 553 (format-time-string "%d %b %y"))
9565745a
RS
554
555;;; RCS 3 date
556
557(defun time-stamp-yy/mm/dd ()
e1f40b28 558 "Return the current date as a string in \"YY/MM/DD\" form."
b8944601 559 (format-time-string "%y/%m/%d"))
9565745a
RS
560
561;;; RCS 5 date
562
563(defun time-stamp-yyyy/mm/dd ()
e1f40b28 564 "Return the current date as a string in \"YYYY/MM/DD\" form."
b8944601 565 (format-time-string "%Y/%m/%d"))
9565745a 566
e1f40b28 567;;; ISO 8601 date
9565745a 568
e1f40b28
RS
569(defun time-stamp-yyyy-mm-dd ()
570 "Return the current date as a string in \"YYYY-MM-DD\" form."
b8944601 571 (format-time-string "%Y-%m-%d"))
9565745a 572
e1f40b28
RS
573(defun time-stamp-yymmdd ()
574 "Return the current date as a string in \"YYMMDD\" form."
b8944601 575 (format-time-string "%y%m%d"))
9565745a
RS
576
577(defun time-stamp-hh:mm:ss ()
e1f40b28 578 "Return the current time as a string in \"HH:MM:SS\" form."
b8944601 579 (format-time-string "%T"))
9565745a 580
9565745a 581(defun time-stamp-hhmm ()
e1f40b28 582 "Return the current time as a string in \"HHMM\" form."
b8944601 583 (format-time-string "%H%M"))
9565745a
RS
584
585(provide 'time-stamp)
586
587;;; time-stamp.el ends here