1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs
3 ;; Copyright 1989, 1993, 1994, 1995, 1997, 2000, 2001
4 ;;; Free Software Foundation, Inc.
6 ;; Maintainer's Time-stamp: <2000-12-04 16:06:50 gildea>
7 ;; Maintainer: Stephen Gildea <gildea@alum.mit.edu>
10 ;; This file is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This file is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; A template in a file can be updated with a new time stamp when
28 ;; you save the file. For example:
29 ;; static char *ts = "sdmain.c Time-stamp: <1996-08-13 10:20:51 gildea>";
30 ;; See the top of `time-stamp.el' for another example.
32 ;; To use time-stamping, add this line to your .emacs file:
33 ;; (add-hook 'write-file-hooks 'time-stamp)
34 ;; Now any time-stamp templates in your files will be updated automatically.
36 ;; See the documentation for the functions `time-stamp'
37 ;; and `time-stamp-toggle-active' for details.
41 (defgroup time-stamp nil
42 "Maintain last change time stamps in files edited by Emacs."
46 (defcustom time-stamp-format
"%:y-%02m-%02d %02H:%02M:%02S %u"
47 "*Format of the string inserted by \\[time-stamp].
48 The value may be a string or a list. Lists are supported only for
49 backward compatibility; see variable `time-stamp-old-format-warn'.
51 A string is used verbatim except for character sequences beginning
52 with %, as follows. The values of non-numeric formatted items depend
53 on the locale setting recorded in `locale-coding-system'. The
54 examples here are for the default (`C') locale.
56 %:a weekday name: `Monday'. %#A gives uppercase: `MONDAY'
57 %3a abbreviated weekday: `Mon'. %3A gives uppercase: `MON'
58 %:b month name: `January'. %#B gives uppercase: `JANUARY'
59 %3b abbreviated month: `Jan'. %3B gives uppercase: `JAN'
61 %02H 24-hour clock hour
62 %02I 12-hour clock hour
65 %#p `am' or `pm'. %P gives uppercase: `AM' or `PM'
67 %w day number of week, Sunday is 0
68 %02y 2-digit year: `97' %:y 4-digit year: `1997'
69 %z time zone name: `est'. %Z gives uppercase: `EST'
72 %% a literal percent character: `%'
73 %f file name without directory %F gives absolute pathname
75 %u user's login name %U user's full name
78 Decimal digits between the % and the type character specify the
79 field width. Strings are truncated on the right; years on the left.
80 A leading zero in the field width zero-fills a number.
82 For example, to get the format used by the `date' command,
83 use \"%3a %3b %2d %02H:%02M:%02S %Z %:y\".
85 In the future these formats will be aligned more with `format-time-string'.
86 Because of this transition, the default padding for numeric formats will
87 change in a future version. Therefore either a padding width should be
88 specified, or the : modifier should be used to explicitly request the
93 (defcustom time-stamp-active t
94 "*Non-nil to enable time-stamping of buffers by \\[time-stamp].
95 Can be toggled by \\[time-stamp-toggle-active].
96 See also the variable `time-stamp-warn-inactive'."
100 (defcustom time-stamp-warn-inactive t
101 "Have \\[time-stamp] warn if a buffer did not get time-stamped.
102 If non-nil, a warning is displayed if `time-stamp-active' disables time
103 stamping and the buffer contains a template that would otherwise have
108 (defcustom time-stamp-old-format-warn
'ask
109 "Action if `time-stamp-format' is an old-style list.
110 If `error', the format is not used. If `ask', the user is queried about
111 using the time-stamp-format. If `warn', a warning is displayed.
112 If nil, no notification is given."
113 :type
'(choice (const :tag
"Don't use the format" error
)
116 (const :tag
"No notification" nil
))
119 (defcustom time-stamp-time-zone nil
120 "If non-nil, a string naming the timezone to be used by \\[time-stamp].
121 Format is the same as that used by the environment variable TZ on your system."
122 :type
'(choice (const nil
) string
)
126 ;;; Do not change time-stamp-line-limit, time-stamp-start,
127 ;;; time-stamp-end, time-stamp-pattern, time-stamp-inserts-lines,
128 ;;; or time-stamp-count in your .emacs or you will be incompatible
129 ;;; with other people's files! If you must change them, do so only
130 ;;; in the local variables section of the file itself.
133 (defvar time-stamp-line-limit
8 ;Do not change!
134 "Lines of a file searched; positive counts from start, negative from end.
135 The patterns `time-stamp-start' and `time-stamp-end' must be found in
136 the first (last) `time-stamp-line-limit' lines of the file for the
137 file to be time-stamped by \\[time-stamp]. A value of 0 searches the
138 entire buffer (use with care).
140 Do not change `time-stamp-line-limit', `time-stamp-start', or
141 `time-stamp-end' for yourself or you will be incompatible
142 with other people's files! If you must change them for some application,
143 do so in the local variables section of the time-stamped file itself.")
146 (defvar time-stamp-start
"Time-stamp:[ \t]+\\\\?[\"<]+" ;Do not change!
147 "Regexp after which the time stamp is written by \\[time-stamp].
148 See also the variables `time-stamp-end' and `time-stamp-line-limit'.
150 Do not change `time-stamp-line-limit', `time-stamp-start', or
151 `time-stamp-end' for yourself or you will be incompatible
152 with other people's files! If you must change them for some application,
153 do so in the local variables section of the time-stamped file itself.")
156 (defvar time-stamp-end
"\\\\?[\">]" ;Do not change!
157 "Regexp marking the text after the time stamp.
158 \\[time-stamp] deletes the text between the first match of `time-stamp-start'
159 and the following match of `time-stamp-end', then writes the
160 time stamp specified by `time-stamp-format' between them.
162 The end text normally starts on the same line as the start text ends,
163 but if there are any newlines in `time-stamp-format', the same number
164 of newlines must separate the start and end. \\[time-stamp] tries
165 to not change the number of lines in the buffer. `time-stamp-inserts-lines'
166 controls this behavior.
168 Do not change `time-stamp-line-limit', `time-stamp-start', `time-stamp-end',
169 or `time-stamp-inserts-lines' for yourself or you will be incompatible
170 with other people's files! If you must change them for some application,
171 do so in the local variables section of the time-stamped file itself.")
174 (defvar time-stamp-inserts-lines nil
;Do not change!
175 "Whether time-stamp can change the number of lines in a file.
176 If nil, \\[time-stamp] skips as many lines as there are newlines in
177 `time-stamp-format' before looking for the `time-stamp-end' pattern,
178 thus it tries not to change the number of lines in the buffer.
179 If non-nil, \\[time-stamp] starts looking for the end pattern
180 immediately after the start pattern. This behavior can cause
181 unexpected changes in the buffer if used carelessly, but it is useful
182 for generating repeated time stamps.
184 Do not change `time-stamp-end' or `time-stamp-inserts-lines' for
185 yourself or you will be incompatible with other people's files!
186 If you must change them for some application, do so in the local
187 variables section of the time-stamped file itself.")
190 (defvar time-stamp-count
1 ;Do not change!
191 "How many templates \\[time-stamp] will look for in a buffer.
192 The same time-stamp will be written in each case.
194 Do not change `time-stamp-count' for yourself or you will be
195 incompatible with other people's files! If you must change it for
196 some application, do so in the local variables section of the
197 time-stamped file itself.")
200 (defvar time-stamp-pattern
"%%" ;Do not change!
201 "Convenience variable setting all `time-stamp' location and format values.
202 This string has four parts, each of which is optional.
203 These four parts set `time-stamp-line-limit', `time-stamp-start',
204 `time-stamp-format', and `time-stamp-end'. See the documentation
205 for each of these variables for details.
207 The first part is a number followed by a slash; the number sets the number
208 of lines at the beginning (negative counts from end) of the file searched
209 for the time-stamp. The number and the slash may be omitted to use the
212 The second part is a regexp identifying the pattern preceding the time stamp.
213 This part may be omitted to use the normal pattern.
215 The third part specifies the format of the time-stamp inserted. See
216 the documentation for `time-stamp-format' for details. Specify this
217 part as \"%%\" to use the normal format.
219 The fourth part is a regexp identifying the pattern following the time stamp.
220 This part may be omitted to use the normal pattern.
222 As an example, the default behavior can be specified something like this:
223 \"8/Time-stamp: [\\\"<]%:y-%02m-%02d %02H:%02M:%02S %u[\\\">]\"
225 Do not change `time-stamp-pattern' for yourself or you will be incompatible
226 with other people's files! Set it only in the local variables section
227 of the time-stamped file itself.")
233 "Update the time stamp string(s) in the buffer.
234 A template in a file can be automatically updated with a new time stamp
235 every time you save the file. Add this line to your .emacs file:
236 (add-hook 'write-file-hooks 'time-stamp)
237 Normally the template must appear in the first 8 lines of a file and
238 look like one of the following:
241 The time stamp is written between the brackets or quotes:
242 Time-stamp: <1998-02-18 10:20:51 gildea>
243 The time stamp is updated only if the variable `time-stamp-active' is non-nil.
244 The format of the time stamp is set by the variable `time-stamp-format'.
245 The variables `time-stamp-line-limit', `time-stamp-start', `time-stamp-end',
246 `time-stamp-count', and `time-stamp-inserts-lines' control finding the
249 (let ((line-limit time-stamp-line-limit
)
250 (ts-start time-stamp-start
)
251 (ts-format time-stamp-format
)
252 (ts-end time-stamp-end
)
253 (ts-count time-stamp-count
)
258 (if (stringp time-stamp-pattern
)
260 (string-match "\\`\\(\\(-?[0-9]+\\)/\\)?\\([^%]+\\)?\\(\\(.\\|\n\\)*%[-.,:@+_ #^()0-9]*[A-Za-z%]\\)?\\([^%]+\\)?\\'" time-stamp-pattern
)
261 (and (match-beginning 2)
263 (string-to-int (match-string 2 time-stamp-pattern
))))
264 (and (match-beginning 3)
265 (setq ts-start
(match-string 3 time-stamp-pattern
)))
266 (and (match-beginning 4)
267 (not (string-equal (match-string 4 time-stamp-pattern
) "%%"))
268 (setq ts-format
(match-string 4 time-stamp-pattern
)))
269 (and (match-beginning 6)
270 (setq ts-end
(match-string 6 time-stamp-pattern
)))))
271 (cond ((not (integerp line-limit
))
273 (message "time-stamp-line-limit is not an integer")
275 (cond ((not (integerp ts-count
))
277 (message "time-stamp-count is not an integer")
280 ;; We need to call time-stamp-once at least once
281 ;; to output any warnings about time-stamp not being active.
283 ;; Figure out what lines the end should be on.
284 (if (stringp ts-format
)
286 (while (string-match "\n" ts-format nl-start
)
287 (setq format-lines
(1+ format-lines
) nl-start
(match-end 0)))))
289 (while (string-match "\n" ts-end nl-start
)
290 (setq end-lines
(1+ end-lines
) nl-start
(match-end 0))))
291 ;; Find overall what lines to look at
295 (cond ((> line-limit
0)
296 (goto-char (setq start
(point-min)))
297 (forward-line line-limit
)
298 (setq search-limit
(point)))
300 (goto-char (setq search-limit
(point-max)))
301 (forward-line line-limit
)
302 (setq start
(point)))
303 (t ;0 => no limit (use with care!)
304 (setq start
(point-min))
305 (setq search-limit
(point-max))))))
307 (< start search-limit
)
309 (setq start
(time-stamp-once start search-limit ts-start ts-end
310 ts-format format-lines end-lines
))
311 (setq ts-count
(1- ts-count
))))
312 ;; be sure to return nil so can be used on write-file-hooks
315 (defun time-stamp-once (start search-limit ts-start ts-end
316 ts-format format-lines end-lines
)
317 "Update one time-stamp. Internal routine called by \\[time-stamp].
318 Returns the end point, which is where `time-stamp' begins the next search."
319 (let ((case-fold-search nil
)
326 ;; Find the location of the time stamp.
327 (while (and (< (goto-char start
) search-limit
)
329 (re-search-forward ts-start search-limit
'move
))
331 (if (not time-stamp-inserts-lines
)
332 (forward-line format-lines
))
333 (setq end-search-start
(max start
(point)))
334 (if (= (forward-line end-lines
) 0)
336 (and (bolp) (backward-char))
337 (let ((line-end (min (point) search-limit
)))
338 (if (>= line-end end-search-start
)
340 (goto-char end-search-start
)
341 (if (re-search-forward ts-end line-end t
)
343 (setq end
(match-beginning 0))
344 (setq end-length
(- (match-end 0) end
))))))))))))
347 ;; do all warnings outside save-excursion
349 ((not time-stamp-active
)
350 (if time-stamp-warn-inactive
351 ;; don't signal an error in a write-file-hook
353 (message "Warning: time-stamp-active is off; did not time-stamp buffer.")
355 ((not (and (stringp ts-start
)
357 (message "time-stamp-start or time-stamp-end is not a string")
360 (let ((new-time-stamp (time-stamp-string ts-format
)))
361 (if (and (stringp new-time-stamp
)
362 (not (string-equal (buffer-substring start end
)
367 (delete-region start end
)
369 (insert-and-inherit new-time-stamp
)
371 ;; remove any tabs used to format time stamp
372 (if (search-backward "\t" start t
)
375 (setq end
(point))))))))))))
376 ;; return the location after this time stamp, if there was one
378 (+ end end-length
))))
382 (defun time-stamp-toggle-active (&optional arg
)
383 "Toggle `time-stamp-active', setting whether \\[time-stamp] updates a buffer.
384 With arg, turn time stamping on if and only if arg is positive."
386 (setq time-stamp-active
388 (not time-stamp-active
)
389 (> (prefix-numeric-value arg
) 0)))
390 (message "time-stamp is now %s." (if time-stamp-active
"active" "off")))
393 (defun time-stamp-string (&optional ts-format
)
394 "Generate the new string to be inserted by \\[time-stamp].
395 Optionally use format TS-FORMAT instead of `time-stamp-format' to
398 (setq ts-format time-stamp-format
))
399 (if (stringp ts-format
)
400 (if (stringp time-stamp-time-zone
)
401 (let ((ts-real-time-zone (getenv "TZ")))
404 (setenv "TZ" time-stamp-time-zone
)
406 (time-stamp-string-preprocess ts-format
)))
407 (setenv "TZ" ts-real-time-zone
)))
409 (time-stamp-string-preprocess ts-format
)))
410 ;; handle version 1 compatibility
411 (cond ((or (eq time-stamp-old-format-warn
'error
)
412 (and (eq time-stamp-old-format-warn
'ask
)
413 (not (y-or-n-p "Use non-string time-stamp-format? "))))
414 (message "Warning: no time-stamp: time-stamp-format not a string")
418 (cond ((eq time-stamp-old-format-warn
'warn
)
419 (message "Obsolescent time-stamp-format type; should be string")
421 (time-stamp-fconcat ts-format
" ")))))
423 (defconst time-stamp-no-file
"(no file)"
424 "String to use when the buffer is not associated with a file.")
426 ;;; time-stamp is transitioning to using the new, expanded capabilities
427 ;;; of format-time-string. During the process, this function implements
428 ;;; intermediate, compatible formats and complains about old, soon to
429 ;;; be unsupported, formats. This function will get a lot (a LOT) shorter
430 ;;; when the transition is complete and we can just pass most things
431 ;;; straight through to format-time-string.
432 ;;; At all times, all the formats recommended in the doc string
433 ;;; of time-stamp-format will work not only in the current version of
434 ;;; Emacs, but in all versions that have been released within the past
436 ;;; The : modifier is a temporary conversion feature used to resolve
437 ;;; ambiguous formats--formats that are changing (over time) incompatibly.
438 (defun time-stamp-string-preprocess (format &optional time
)
439 "Use a FORMAT to format date, time, file, and user information.
440 Optional second argument TIME is only for testing.
441 Implements non-time extensions to `format-time-string'
442 and all time-stamp-format compatibility."
443 (let ((fmt-len (length format
))
450 alt-form change-case require-padding
452 (while (< ind fmt-len
)
453 (setq cur-char
(aref format ind
))
459 ;; eat any additional args to allow for future expansion
460 (setq alt-form nil change-case nil require-padding nil field-width
"")
463 (setq cur-char
(if (< ind fmt-len
)
467 (eq ?
, cur-char
) (eq ?
: cur-char
) (eq ?
@ cur-char
)
468 (eq ?- cur-char
) (eq ?
+ cur-char
) (eq ?_ cur-char
)
469 (eq ?\ cur-char
) (eq ?
# cur-char
) (eq ?^ cur-char
)
470 (and (eq ?\
( cur-char
)
471 (not (eq prev-char ?
\\))
472 (setq paren-level
(1+ paren-level
)))
473 (if (and (eq ?\
) cur-char
)
474 (not (eq prev-char ?
\\))
476 (setq paren-level
(1- paren-level
))
477 (and (> paren-level
0)
479 (if (and (<= ?
0 cur-char
) (>= ?
9 cur-char
))
481 (let ((field-index ind
))
484 (setq cur-char
(if (< ind fmt-len
)
487 (and (<= ?
0 cur-char
) (>= ?
9 cur-char
))))
488 (setq field-width
(substring format field-index ind
))
491 (setq prev-char cur-char
)
492 ;; some characters we actually use
493 (cond ((eq cur-char ?
:)
496 (setq change-case t
))))
501 ((eq cur-char ?a
) ;day of week
503 (format-time-string "%#A" time
)
504 (or alt-form
(not (string-equal field-width
""))
505 (time-stamp-conv-warn "%a" "%:a"))
506 (if (and alt-form
(not (string-equal field-width
"")))
507 "" ;discourage "%:3a"
508 (format-time-string "%A" time
))))
511 (format-time-string "%A" time
)
512 (or change-case
(not (string-equal field-width
""))
513 (time-stamp-conv-warn "%A" "%#A"))
514 (format-time-string "%#A" time
)))
515 ((eq cur-char ?b
) ;month name
517 (format-time-string "%#B" time
)
518 (or alt-form
(not (string-equal field-width
""))
519 (time-stamp-conv-warn "%b" "%:b"))
520 (if (and alt-form
(not (string-equal field-width
"")))
521 "" ;discourage "%:3b"
522 (format-time-string "%B" time
))))
525 (format-time-string "%B" time
)
526 (or change-case
(not (string-equal field-width
""))
527 (time-stamp-conv-warn "%B" "%#B"))
528 (format-time-string "%#B" time
)))
529 ((eq cur-char ?d
) ;day of month, 1-31
530 (time-stamp-do-number cur-char alt-form field-width time
))
531 ((eq cur-char ?H
) ;hour, 0-23
532 (time-stamp-do-number cur-char alt-form field-width time
))
533 ((eq cur-char ?I
) ;hour, 1-12
534 (time-stamp-do-number cur-char alt-form field-width time
))
535 ((eq cur-char ?m
) ;month number, 1-12
536 (time-stamp-do-number cur-char alt-form field-width time
))
537 ((eq cur-char ?M
) ;minute, 0-59
538 (time-stamp-do-number cur-char alt-form field-width time
))
539 ((eq cur-char ?p
) ;am or pm
541 (time-stamp-conv-warn "%p" "%#p"))
542 (format-time-string "%#p" time
))
543 ((eq cur-char ?P
) ;AM or PM
544 (format-time-string "%p" time
))
545 ((eq cur-char ?S
) ;seconds, 00-60
546 (time-stamp-do-number cur-char alt-form field-width time
))
547 ((eq cur-char ?w
) ;weekday number, Sunday is 0
548 (format-time-string "%w" time
))
549 ((eq cur-char ?y
) ;year
550 (or alt-form
(not (string-equal field-width
""))
551 (time-stamp-conv-warn "%y" "%:y"))
552 (string-to-int (format-time-string "%Y" time
)))
553 ((eq cur-char ?Y
) ;4-digit year, new style
554 (string-to-int (format-time-string "%Y" time
)))
555 ((eq cur-char ?z
) ;time zone lower case
557 "" ;discourage %z variations
558 (format-time-string "%#Z" time
)))
561 (format-time-string "%#Z" time
)
562 (format-time-string "%Z" time
)))
563 ((eq cur-char ?f
) ;buffer-file-name, base name only
565 (file-name-nondirectory buffer-file-name
)
567 ((eq cur-char ?F
) ;buffer-file-name, full path
570 ((eq cur-char ?s
) ;system name
572 ((eq cur-char ?u
) ;user name
574 ((eq cur-char ?U
) ;user full name
576 ((eq cur-char ?l
) ;logname (undocumented user name alt)
578 ((eq cur-char ?L
) ;(undocumented alt user full name)
580 ((eq cur-char ?h
) ;mail host name
581 (time-stamp-mail-host-name))
584 (format (format "%%%s%c"
586 (if (numberp field-result
) ?d ?s
))
587 (or field-result
""))))
588 (let* ((initial-length (length padded-result
))
589 (desired-length (if (string-equal field-width
"")
591 (string-to-int field-width
))))
592 (if (> initial-length desired-length
)
593 ;; truncate strings on right, years on left
594 (if (stringp field-result
)
595 (substring padded-result
0 desired-length
)
597 (substring padded-result
(- desired-length
))
598 padded-result
)) ;non-year numbers don't truncate
601 (char-to-string cur-char
)))))
605 (defun time-stamp-do-number (format-char alt-form field-width time
)
606 "Handle compatible FORMAT-CHAR where only default width/padding will change.
607 ALT-FORM is whether `#' specified. FIELD-WIDTH is the string
608 width specification or \"\". TIME is the time to convert."
609 (let ((format-string (concat "%" (char-to-string format-char
))))
610 (and (not alt-form
) (string-equal field-width
"")
611 (time-stamp-conv-warn format-string
612 (format "%%:%c" format-char
)))
613 (if (and alt-form
(not (string-equal field-width
"")))
614 "" ;discourage "%:2d" and the like
615 (string-to-int (format-time-string format-string time
)))))
617 (defvar time-stamp-conversion-warn t
618 "Warn about soon-to-be-unsupported forms in `time-stamp-format'.
619 If nil, these warnings are disabled, which would be a bad idea!
620 You really need to update your files instead.
622 The new formats will work with old versions of Emacs.
623 New formats are being recommended now to allow `time-stamp-format'
624 to change in the future to be compatible with `format-time-string'.
625 The new forms being recommended now will continue to work then.")
628 (defun time-stamp-conv-warn (old-form new-form
)
629 "Display a warning about a soon-to-be-obsolete format."
631 (time-stamp-conversion-warn
633 (set-buffer (get-buffer-create "*Time-stamp-compatibility*"))
634 (goto-char (point-max))
638 "The formats recognized in time-stamp-format will change in a future release\n"
639 "to be compatible with the new, expanded format-time-string function.\n\n"
640 "The following obsolescent time-stamp-format construct(s) were found:\n\n")))
641 (insert "\"" old-form
"\" -- use " new-form
"\n"))
642 (display-buffer "*Time-stamp-compatibility*"))))
646 (defun time-stamp-mail-host-name ()
647 "Return the name of the host where the user receives mail.
648 This is the value of `mail-host-address' if bound and a string,
649 otherwise the value of the function `system-name'."
650 (or (and (boundp 'mail-host-address
)
651 (stringp mail-host-address
)
655 ;;; the rest of this file is for version 1 compatibility
657 (defun time-stamp-fconcat (list sep
)
658 "Similar to (mapconcat 'funcall LIST SEP) but LIST allows literals.
659 If an element of LIST is a symbol, it is funcalled to get the string to use;
660 the separator SEP is used between two strings obtained by funcalling a
661 symbol. Otherwise the element itself is inserted; no separator is used
663 (let ((return-string "")
666 (cond ((symbolp (car list
))
668 (setq return-string
(concat return-string sep
)))
669 (setq return-string
(concat return-string
(funcall (car list
))))
670 (setq insert-sep-p t
))
672 (setq return-string
(concat return-string
(car list
)))
673 (setq insert-sep-p nil
)))
674 (setq list
(cdr list
)))
677 ;;; Some functions used in time-stamp-format
679 ;;; Could generate most of a message-id with
680 ;;; '(time-stamp-yymmdd "" time-stamp-hhmm "@" time-stamp-mail-host-name)
682 ;;; pretty form, suitable for a title page
684 (defun time-stamp-month-dd-yyyy ()
685 "Return the current date as a string in \"Month DD, YYYY\" form."
686 (format-time-string "%B %e, %Y"))
688 (defun time-stamp-dd/mm
/yyyy
()
689 "Return the current date as a string in \"DD/MM/YYYY\" form."
690 (format-time-string "%d/%m/%Y"))
692 ;;; same as __DATE__ in ANSI C
694 (defun time-stamp-mon-dd-yyyy ()
695 "Return the current date as a string in \"Mon DD YYYY\" form.
696 The first character of DD is space if the value is less than 10."
697 (format-time-string "%b %d %Y"))
701 (defun time-stamp-dd-mon-yy ()
702 "Return the current date as a string in \"DD Mon YY\" form."
703 (format-time-string "%d %b %y"))
707 (defun time-stamp-yy/mm
/dd
()
708 "Return the current date as a string in \"YY/MM/DD\" form."
709 (format-time-string "%y/%m/%d"))
713 (defun time-stamp-yyyy/mm
/dd
()
714 "Return the current date as a string in \"YYYY/MM/DD\" form."
715 (format-time-string "%Y/%m/%d"))
719 (defun time-stamp-yyyy-mm-dd ()
720 "Return the current date as a string in \"YYYY-MM-DD\" form."
721 (format-time-string "%Y-%m-%d"))
723 (defun time-stamp-yymmdd ()
724 "Return the current date as a string in \"YYMMDD\" form."
725 (format-time-string "%y%m%d"))
727 (defun time-stamp-hh:mm
:ss
()
728 "Return the current time as a string in \"HH:MM:SS\" form."
729 (format-time-string "%T"))
731 (defun time-stamp-hhmm ()
732 "Return the current time as a string in \"HHMM\" form."
733 (format-time-string "%H%M"))
735 (provide 'time-stamp
)
737 ;;; time-stamp.el ends here