1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs
3 ;; Copyright 1989, 1993, 1994, 1995, 1997, 2000
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 with %:
53 %:a weekday name: `Monday'. %#A gives uppercase: `MONDAY'
54 %3a abbreviated weekday: `Mon'. %3A gives uppercase: `MON'
55 %:b month name: `January'. %#B gives uppercase: `JANUARY'
56 %3b abbreviated month: `Jan'. %3B gives uppercase: `JAN'
58 %02H 24-hour clock hour
59 %02I 12-hour clock hour
62 %#p `am' or `pm'. %P gives uppercase: `AM' or `PM'
64 %w day number of week, Sunday is 0
65 %02y 2-digit year: `97' %:y 4-digit year: `1997'
66 %z time zone name: `est'. %Z gives uppercase: `EST'
69 %% a literal percent character: `%'
70 %f file name without directory %F gives absolute pathname
72 %u user's login name %U user's full name
75 Decimal digits between the % and the type character specify the
76 field width. Strings are truncated on the right; years on the left.
77 A leading zero in the field width zero-fills a number.
79 For example, to get the format used by the `date' command,
80 use \"%3a %3b %2d %02H:%02M:%02S %Z %:y\".
82 In the future these formats will be aligned more with `format-time-string'.
83 Because of this transition, the default padding for numeric formats will
84 change in a future version. Therefore either a padding width should be
85 specified, or the : modifier should be used to explicitly request the
90 (defcustom time-stamp-active t
91 "*Non-nil to enable time-stamping of buffers by \\[time-stamp].
92 Can be toggled by \\[time-stamp-toggle-active].
93 See also the variable `time-stamp-warn-inactive'."
97 (defcustom time-stamp-warn-inactive t
98 "Have \\[time-stamp] warn if a buffer did not get time-stamped.
99 If non-nil, a warning is displayed if `time-stamp-active' disables time
100 stamping and the buffer contains a template that would otherwise have
105 (defcustom time-stamp-old-format-warn
'ask
106 "Action if `time-stamp-format' is an old-style list.
107 If `error', the format is not used. If `ask', the user is queried about
108 using the time-stamp-format. If `warn', a warning is displayed.
109 If nil, no notification is given."
110 :type
'(choice (const :tag
"Don't use the format" error
)
113 (const :tag
"No notification" nil
))
116 (defcustom time-stamp-time-zone nil
117 "If non-nil, a string naming the timezone to be used by \\[time-stamp].
118 Format is the same as that used by the environment variable TZ on your system."
119 :type
'(choice (const nil
) string
)
123 ;;; Do not change time-stamp-line-limit, time-stamp-start,
124 ;;; time-stamp-end, time-stamp-pattern, time-stamp-inserts-lines,
125 ;;; or time-stamp-count in your .emacs or you will be incompatible
126 ;;; with other people's files! If you must change them, do so only
127 ;;; in the local variables section of the file itself.
130 (defvar time-stamp-line-limit
8 ;Do not change!
131 "Lines of a file searched; positive counts from start, negative from end.
132 The patterns `time-stamp-start' and `time-stamp-end' must be found in
133 the first (last) `time-stamp-line-limit' lines of the file for the
134 file to be time-stamped by \\[time-stamp]. A value of 0 searches the
135 entire buffer (use with care).
137 Do not change `time-stamp-line-limit', `time-stamp-start', or
138 `time-stamp-end' for yourself or you will be incompatible
139 with other people's files! If you must change them for some application,
140 do so in the local variables section of the time-stamped file itself.")
143 (defvar time-stamp-start
"Time-stamp:[ \t]+\\\\?[\"<]+" ;Do not change!
144 "Regexp after which the time stamp is written by \\[time-stamp].
145 See also the variables `time-stamp-end' and `time-stamp-line-limit'.
147 Do not change `time-stamp-line-limit', `time-stamp-start', or
148 `time-stamp-end' for yourself or you will be incompatible
149 with other people's files! If you must change them for some application,
150 do so in the local variables section of the time-stamped file itself.")
153 (defvar time-stamp-end
"\\\\?[\">]" ;Do not change!
154 "Regexp marking the text after the time stamp.
155 \\[time-stamp] deletes the text between the first match of `time-stamp-start'
156 and the following match of `time-stamp-end', then writes the
157 time stamp specified by `time-stamp-format' between them.
159 The end text normally starts on the same line as the start text ends,
160 but if there are any newlines in `time-stamp-format', the same number
161 of newlines must separate the start and end. \\[time-stamp] tries
162 to not change the number of lines in the buffer. `time-stamp-inserts-lines'
163 controls this behavior.
165 Do not change `time-stamp-line-limit', `time-stamp-start', `time-stamp-end',
166 or `time-stamp-inserts-lines' for yourself or you will be incompatible
167 with other people's files! If you must change them for some application,
168 do so in the local variables section of the time-stamped file itself.")
171 (defvar time-stamp-inserts-lines nil
;Do not change!
172 "Whether time-stamp can change the number of lines in a file.
173 If nil, \\[time-stamp] skips as many lines as there are newlines in
174 `time-stamp-format' before looking for the `time-stamp-end' pattern,
175 thus it tries not to change the number of lines in the buffer.
176 If non-nil, \\[time-stamp] starts looking for the end pattern
177 immediately after the start pattern. This behavior can cause
178 unexpected changes in the buffer if used carelessly, but it is useful
179 for generating repeated time stamps.
181 Do not change `time-stamp-end' or `time-stamp-inserts-lines' for
182 yourself or you will be incompatible with other people's files!
183 If you must change them for some application, do so in the local
184 variables section of the time-stamped file itself.")
187 (defvar time-stamp-count
1 ;Do not change!
188 "How many templates \\[time-stamp] will look for in a buffer.
189 The same time-stamp will be written in each case.
191 Do not change `time-stamp-count' for yourself or you will be
192 incompatible with other people's files! If you must change it for
193 some application, do so in the local variables section of the
194 time-stamped file itself.")
197 (defvar time-stamp-pattern
"%%" ;Do not change!
198 "Convenience variable setting all `time-stamp' location and format values.
199 This string has four parts, each of which is optional.
200 These four parts set `time-stamp-line-limit', `time-stamp-start',
201 `time-stamp-format', and `time-stamp-end'. See the documentation
202 for each of these variables for details.
204 The first part is a number followed by a slash; the number sets the number
205 of lines at the beginning (negative counts from end) of the file searched
206 for the time-stamp. The number and the slash may be omitted to use the
209 The second part is a regexp identifying the pattern preceding the time stamp.
210 This part may be omitted to use the normal pattern.
212 The third part specifies the format of the time-stamp inserted. See
213 the documentation for `time-stamp-format' for details. Specify this
214 part as \"%%\" to use the normal format.
216 The fourth part is a regexp identifying the pattern following the time stamp.
217 This part may be omitted to use the normal pattern.
219 As an example, the default behavior can be specified something like this:
220 \"8/Time-stamp: [\\\"<]%:y-%02m-%02d %02H:%02M:%02S %u[\\\">]\"
222 Do not change `time-stamp-pattern' for yourself or you will be incompatible
223 with other people's files! Set it only in the local variables section
224 of the time-stamped file itself.")
230 "Update the time stamp string(s) in the buffer.
231 A template in a file can be automatically updated with a new time stamp
232 every time you save the file. Add this line to your .emacs file:
233 (add-hook 'write-file-hooks 'time-stamp)
234 Normally the template must appear in the first 8 lines of a file and
235 look like one of the following:
238 The time stamp is written between the brackets or quotes:
239 Time-stamp: <1998-02-18 10:20:51 gildea>
240 The time stamp is updated only if the variable `time-stamp-active' is non-nil.
241 The format of the time stamp is set by the variable `time-stamp-format'.
242 The variables `time-stamp-line-limit', `time-stamp-start', `time-stamp-end',
243 `time-stamp-count', and `time-stamp-inserts-lines' control finding the
246 (let ((line-limit time-stamp-line-limit
)
247 (ts-start time-stamp-start
)
248 (ts-format time-stamp-format
)
249 (ts-end time-stamp-end
)
250 (ts-count time-stamp-count
)
255 (if (stringp time-stamp-pattern
)
257 (string-match "\\`\\(\\(-?[0-9]+\\)/\\)?\\([^%]+\\)?\\(\\(.\\|\n\\)*%[-.,:@+_ #^()0-9]*[A-Za-z%]\\)?\\([^%]+\\)?\\'" time-stamp-pattern
)
258 (and (match-beginning 2)
260 (string-to-int (match-string 2 time-stamp-pattern
))))
261 (and (match-beginning 3)
262 (setq ts-start
(match-string 3 time-stamp-pattern
)))
263 (and (match-beginning 4)
264 (not (string-equal (match-string 4 time-stamp-pattern
) "%%"))
265 (setq ts-format
(match-string 4 time-stamp-pattern
)))
266 (and (match-beginning 6)
267 (setq ts-end
(match-string 6 time-stamp-pattern
)))))
268 (cond ((not (integerp line-limit
))
270 (message "time-stamp-line-limit is not an integer")
272 (cond ((not (integerp ts-count
))
274 (message "time-stamp-count is not an integer")
277 ;; We need to call time-stamp-once at least once
278 ;; to output any warnings about time-stamp not being active.
280 ;; Figure out what lines the end should be on.
281 (if (stringp ts-format
)
283 (while (string-match "\n" ts-format nl-start
)
284 (setq format-lines
(1+ format-lines
) nl-start
(match-end 0)))))
286 (while (string-match "\n" ts-end nl-start
)
287 (setq end-lines
(1+ end-lines
) nl-start
(match-end 0))))
288 ;; Find overall what lines to look at
292 (cond ((> line-limit
0)
293 (goto-char (setq start
(point-min)))
294 (forward-line line-limit
)
295 (setq search-limit
(point)))
297 (goto-char (setq search-limit
(point-max)))
298 (forward-line line-limit
)
299 (setq start
(point)))
300 (t ;0 => no limit (use with care!)
301 (setq start
(point-min))
302 (setq search-limit
(point-max))))))
304 (< start search-limit
)
306 (setq start
(time-stamp-once start search-limit ts-start ts-end
307 ts-format format-lines end-lines
))
308 (setq ts-count
(1- ts-count
))))
309 ;; be sure to return nil so can be used on write-file-hooks
312 (defun time-stamp-once (start search-limit ts-start ts-end
313 ts-format format-lines end-lines
)
314 "Update one time-stamp. Internal routine called by \\[time-stamp].
315 Returns the end point, which is where `time-stamp' begins the next search."
316 (let ((case-fold-search nil
)
323 ;; Find the location of the time stamp.
324 (while (and (< (goto-char start
) search-limit
)
326 (re-search-forward ts-start search-limit
'move
))
328 (if (not time-stamp-inserts-lines
)
329 (forward-line format-lines
))
330 (setq end-search-start
(max start
(point)))
331 (if (= (forward-line end-lines
) 0)
333 (and (bolp) (backward-char))
334 (let ((line-end (min (point) search-limit
)))
335 (if (>= line-end end-search-start
)
337 (goto-char end-search-start
)
338 (if (re-search-forward ts-end line-end t
)
340 (setq end
(match-beginning 0))
341 (setq end-length
(- (match-end 0) end
))))))))))))
344 ;; do all warnings outside save-excursion
346 ((not time-stamp-active
)
347 (if time-stamp-warn-inactive
348 ;; don't signal an error in a write-file-hook
350 (message "Warning: time-stamp-active is off; did not time-stamp buffer.")
352 ((not (and (stringp ts-start
)
354 (message "time-stamp-start or time-stamp-end is not a string")
357 (let ((new-time-stamp (time-stamp-string ts-format
)))
358 (if (and (stringp new-time-stamp
)
359 (not (string-equal (buffer-substring start end
)
364 (delete-region start end
)
366 (insert-and-inherit new-time-stamp
)
368 ;; remove any tabs used to format time stamp
369 (if (search-backward "\t" start t
)
372 (setq end
(point))))))))))))
373 ;; return the location after this time stamp, if there was one
375 (+ end end-length
))))
379 (defun time-stamp-toggle-active (&optional arg
)
380 "Toggle `time-stamp-active', setting whether \\[time-stamp] updates a buffer.
381 With arg, turn time stamping on if and only if arg is positive."
383 (setq time-stamp-active
385 (not time-stamp-active
)
386 (> (prefix-numeric-value arg
) 0)))
387 (message "time-stamp is now %s." (if time-stamp-active
"active" "off")))
390 (defun time-stamp-string (&optional ts-format
)
391 "Generate the new string to be inserted by \\[time-stamp].
392 Optionally use FORMAT."
394 (setq ts-format time-stamp-format
))
395 (if (stringp ts-format
)
396 (if (stringp time-stamp-time-zone
)
397 (let ((ts-real-time-zone (getenv "TZ")))
400 (setenv "TZ" time-stamp-time-zone
)
402 (time-stamp-string-preprocess ts-format
)))
403 (setenv "TZ" ts-real-time-zone
)))
405 (time-stamp-string-preprocess ts-format
)))
406 ;; handle version 1 compatibility
407 (cond ((or (eq time-stamp-old-format-warn
'error
)
408 (and (eq time-stamp-old-format-warn
'ask
)
409 (not (y-or-n-p "Use non-string time-stamp-format? "))))
410 (message "Warning: no time-stamp: time-stamp-format not a string")
414 (cond ((eq time-stamp-old-format-warn
'warn
)
415 (message "Obsolescent time-stamp-format type; should be string")
417 (time-stamp-fconcat ts-format
" ")))))
419 (defconst time-stamp-no-file
"(no file)"
420 "String to use when the buffer is not associated with a file.")
422 ;;; time-stamp is transitioning to using the new, expanded capabilities
423 ;;; of format-time-string. During the process, this function implements
424 ;;; intermediate, compatible formats and complains about old, soon to
425 ;;; be unsupported, formats. This function will get a lot (a LOT) shorter
426 ;;; when the transition is complete and we can just pass most things
427 ;;; straight through to format-time-string.
428 ;;; At all times, all the formats recommended in the doc string
429 ;;; of time-stamp-format will work not only in the current version of
430 ;;; Emacs, but in all versions that have been released within the past
432 ;;; The : modifier is a temporary conversion feature used to resolve
433 ;;; ambiguous formats--formats that are changing (over time) incompatibly.
434 (defun time-stamp-string-preprocess (format &optional time
)
435 ;; Use a FORMAT to format date, time, file, and user information.
436 ;; Optional second argument TIME is only for testing.
437 ;; Implements non-time extensions to format-time-string
438 ;; and all time-stamp-format compatibility.
439 (let ((fmt-len (length format
))
446 alt-form change-case require-padding
448 (while (< ind fmt-len
)
449 (setq cur-char
(aref format ind
))
455 ;; eat any additional args to allow for future expansion
456 (setq alt-form nil change-case nil require-padding nil field-width
"")
459 (setq cur-char
(if (< ind fmt-len
)
463 (eq ?
, cur-char
) (eq ?
: cur-char
) (eq ?
@ cur-char
)
464 (eq ?- cur-char
) (eq ?
+ cur-char
) (eq ?_ cur-char
)
465 (eq ?\ cur-char
) (eq ?
# cur-char
) (eq ?^ cur-char
)
466 (and (eq ?\
( cur-char
)
467 (not (eq prev-char ?
\\))
468 (setq paren-level
(1+ paren-level
)))
469 (if (and (eq ?\
) cur-char
)
470 (not (eq prev-char ?
\\))
472 (setq paren-level
(1- paren-level
))
473 (and (> paren-level
0)
475 (if (and (<= ?
0 cur-char
) (>= ?
9 cur-char
))
477 (let ((field-index ind
))
480 (setq cur-char
(if (< ind fmt-len
)
483 (and (<= ?
0 cur-char
) (>= ?
9 cur-char
))))
484 (setq field-width
(substring format field-index ind
))
487 (setq prev-char cur-char
)
488 ;; some characters we actually use
489 (cond ((eq cur-char ?
:)
492 (setq change-case t
))))
497 ((eq cur-char ?a
) ;day of week
499 (format-time-string "%#A" time
)
500 (or alt-form
(not (string-equal field-width
""))
501 (time-stamp-conv-warn "%a" "%:a"))
502 (if (and alt-form
(not (string-equal field-width
"")))
503 "" ;discourage "%:3a"
504 (format-time-string "%A" time
))))
507 (format-time-string "%A" time
)
508 (or change-case
(not (string-equal field-width
""))
509 (time-stamp-conv-warn "%A" "%#A"))
510 (format-time-string "%#A" time
)))
511 ((eq cur-char ?b
) ;month name
513 (format-time-string "%#B" time
)
514 (or alt-form
(not (string-equal field-width
""))
515 (time-stamp-conv-warn "%b" "%:b"))
516 (if (and alt-form
(not (string-equal field-width
"")))
517 "" ;discourage "%:3b"
518 (format-time-string "%B" time
))))
521 (format-time-string "%B" time
)
522 (or change-case
(not (string-equal field-width
""))
523 (time-stamp-conv-warn "%B" "%#B"))
524 (format-time-string "%#B" time
)))
525 ((eq cur-char ?d
) ;day of month, 1-31
526 (time-stamp-do-number cur-char alt-form field-width time
))
527 ((eq cur-char ?H
) ;hour, 0-23
528 (time-stamp-do-number cur-char alt-form field-width time
))
529 ((eq cur-char ?I
) ;hour, 1-12
530 (time-stamp-do-number cur-char alt-form field-width time
))
531 ((eq cur-char ?m
) ;month number, 1-12
532 (time-stamp-do-number cur-char alt-form field-width time
))
533 ((eq cur-char ?M
) ;minute, 0-59
534 (time-stamp-do-number cur-char alt-form field-width time
))
535 ((eq cur-char ?p
) ;am or pm
537 (time-stamp-conv-warn "%p" "%#p"))
538 (format-time-string "%#p" time
))
539 ((eq cur-char ?P
) ;AM or PM
540 (format-time-string "%p" time
))
541 ((eq cur-char ?S
) ;seconds, 00-60
542 (time-stamp-do-number cur-char alt-form field-width time
))
543 ((eq cur-char ?w
) ;weekday number, Sunday is 0
544 (format-time-string "%w" time
))
545 ((eq cur-char ?y
) ;year
546 (or alt-form
(not (string-equal field-width
""))
547 (time-stamp-conv-warn "%y" "%:y"))
548 (string-to-int (format-time-string "%Y" time
)))
549 ((eq cur-char ?Y
) ;4-digit year, new style
550 (string-to-int (format-time-string "%Y" time
)))
551 ((eq cur-char ?z
) ;time zone lower case
553 "" ;discourage %z variations
554 (format-time-string "%#Z" time
)))
557 (format-time-string "%#Z" time
)
558 (format-time-string "%Z" time
)))
559 ((eq cur-char ?f
) ;buffer-file-name, base name only
561 (file-name-nondirectory buffer-file-name
)
563 ((eq cur-char ?F
) ;buffer-file-name, full path
566 ((eq cur-char ?s
) ;system name
568 ((eq cur-char ?u
) ;user name
570 ((eq cur-char ?U
) ;user full name
572 ((eq cur-char ?l
) ;logname (undocumented user name alt)
574 ((eq cur-char ?L
) ;(undocumented alt user full name)
576 ((eq cur-char ?h
) ;mail host name
577 (time-stamp-mail-host-name))
580 (format (format "%%%s%c"
582 (if (numberp field-result
) ?d ?s
))
583 (or field-result
""))))
584 (let* ((initial-length (length padded-result
))
585 (desired-length (if (string-equal field-width
"")
587 (string-to-int field-width
))))
588 (if (> initial-length desired-length
)
589 ;; truncate strings on right, years on left
590 (if (stringp field-result
)
591 (substring padded-result
0 desired-length
)
593 (substring padded-result
(- desired-length
))
594 padded-result
)) ;non-year numbers don't truncate
597 (char-to-string cur-char
)))))
601 (defun time-stamp-do-number (format-char alt-form field-width time
)
602 ;; Handle a compatible FORMAT-CHAR where only
603 ;; the default width/padding will change.
604 ;; ALT-FORM is whether `#' specified. FIELD-WIDTH is the string
605 ;; width specification or "". TIME is the time to convert.
606 (let ((format-string (concat "%" (char-to-string format-char
))))
607 (and (not alt-form
) (string-equal field-width
"")
608 (time-stamp-conv-warn format-string
609 (format "%%:%c" format-char
)))
610 (if (and alt-form
(not (string-equal field-width
"")))
611 "" ;discourage "%:2d" and the like
612 (string-to-int (format-time-string format-string time
)))))
614 (defvar time-stamp-conversion-warn t
615 "Warn about soon-to-be-unsupported forms in `time-stamp-format'.
616 If nil, these warnings are disabled, which would be a bad idea!
617 You really need to update your files instead.
619 The new formats will work with old versions of Emacs.
620 New formats are being recommended now to allow `time-stamp-format'
621 to change in the future to be compatible with `format-time-string'.
622 The new forms being recommended now will continue to work then.")
625 (defun time-stamp-conv-warn (old-form new-form
)
626 ;; Display a warning about a soon-to-be-obsolete format.
628 (time-stamp-conversion-warn
630 (set-buffer (get-buffer-create "*Time-stamp-compatibility*"))
631 (goto-char (point-max))
635 "The formats recognized in time-stamp-format will change in a future release\n"
636 "to be compatible with the new, expanded format-time-string function.\n\n"
637 "The following obsolescent time-stamp-format construct(s) were found:\n\n")))
638 (insert "\"" old-form
"\" -- use " new-form
"\n"))
639 (display-buffer "*Time-stamp-compatibility*"))))
643 (defun time-stamp-mail-host-name ()
644 "Return the name of the host where the user receives mail.
645 This is the value of `mail-host-address' if bound and a string,
646 otherwise the value of the function `system-name'."
647 (or (and (boundp 'mail-host-address
)
648 (stringp mail-host-address
)
652 ;;; the rest of this file is for version 1 compatibility
654 (defun time-stamp-fconcat (list sep
)
655 "Similar to (mapconcat 'funcall LIST SEP) but LIST allows literals.
656 If an element of LIST is a symbol, it is funcalled to get the string to use;
657 the separator SEP is used between two strings obtained by funcalling a
658 symbol. Otherwise the element itself is inserted; no separator is used
660 (let ((return-string "")
663 (cond ((symbolp (car list
))
665 (setq return-string
(concat return-string sep
)))
666 (setq return-string
(concat return-string
(funcall (car list
))))
667 (setq insert-sep-p t
))
669 (setq return-string
(concat return-string
(car list
)))
670 (setq insert-sep-p nil
)))
671 (setq list
(cdr list
)))
674 ;;; Some functions used in time-stamp-format
676 ;;; Could generate most of a message-id with
677 ;;; '(time-stamp-yymmdd "" time-stamp-hhmm "@" time-stamp-mail-host-name)
679 ;;; pretty form, suitable for a title page
681 (defun time-stamp-month-dd-yyyy ()
682 "Return the current date as a string in \"Month DD, YYYY\" form."
683 (format-time-string "%B %e, %Y"))
685 (defun time-stamp-dd/mm
/yyyy
()
686 "Return the current date as a string in \"DD/MM/YYYY\" form."
687 (format-time-string "%d/%m/%Y"))
689 ;;; same as __DATE__ in ANSI C
691 (defun time-stamp-mon-dd-yyyy ()
692 "Return the current date as a string in \"Mon DD YYYY\" form.
693 The first character of DD is space if the value is less than 10."
694 (format-time-string "%b %d %Y"))
698 (defun time-stamp-dd-mon-yy ()
699 "Return the current date as a string in \"DD Mon YY\" form."
700 (format-time-string "%d %b %y"))
704 (defun time-stamp-yy/mm
/dd
()
705 "Return the current date as a string in \"YY/MM/DD\" form."
706 (format-time-string "%y/%m/%d"))
710 (defun time-stamp-yyyy/mm
/dd
()
711 "Return the current date as a string in \"YYYY/MM/DD\" form."
712 (format-time-string "%Y/%m/%d"))
716 (defun time-stamp-yyyy-mm-dd ()
717 "Return the current date as a string in \"YYYY-MM-DD\" form."
718 (format-time-string "%Y-%m-%d"))
720 (defun time-stamp-yymmdd ()
721 "Return the current date as a string in \"YYMMDD\" form."
722 (format-time-string "%y%m%d"))
724 (defun time-stamp-hh:mm
:ss
()
725 "Return the current time as a string in \"HH:MM:SS\" form."
726 (format-time-string "%T"))
728 (defun time-stamp-hhmm ()
729 "Return the current time as a string in \"HHMM\" form."
730 (format-time-string "%H%M"))
732 (provide 'time-stamp
)
734 ;;; time-stamp.el ends here