1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs
3 ;; Copyright 1989, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
5 ;; Maintainer's Time-stamp: <1999-06-26 15:12:53 gildea>
6 ;; Maintainer: Stephen Gildea <gildea@alum.mit.edu>
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)
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.
19 ;; You should have received a copy of the GNU General Public License
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.
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.
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.
35 ;; See the documentation for the functions `time-stamp'
36 ;; and `time-stamp-toggle-active' for details.
40 (defgroup time-stamp nil
41 "Maintain last change time stamps in files edited by Emacs."
45 (defcustom time-stamp-format
"%:y-%02m-%02d %02H:%02M:%02S %u"
46 "*Format of the string inserted by \\[time-stamp].
47 The value may be a string or a list. Lists are supported only for
48 backward compatibility; see variable `time-stamp-old-format-warn'.
50 A string is used verbatim except for character sequences beginning with %:
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'
57 %02H 24-hour clock hour
58 %02I 12-hour clock hour
61 %#p `am' or `pm'. %P gives uppercase: `AM' or `PM'
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'
68 %% a literal percent character: `%'
69 %f file name without directory %F gives absolute pathname
71 %u user's login name %U user's full name
74 Decimal digits between the % and the type character specify the
75 field width. Strings are truncated on the right; years on the left.
76 A leading zero in the field width zero-fills a number.
78 For example, to get the format used by the `date' command,
79 use \"%3a %3b %2d %02H:%02M:%02S %Z %:y\".
81 In the future these formats will be aligned more with `format-time-string'.
82 Because of this transition, the default padding for numeric formats will
83 change in a future version. Therefore either a padding width should be
84 specified, or the : modifier should be used to explicitly request the
89 (defcustom time-stamp-active t
90 "*Non-nil to enable time-stamping of buffers by \\[time-stamp].
91 Can be toggled by \\[time-stamp-toggle-active].
92 See also the variable `time-stamp-warn-inactive'."
96 (defcustom time-stamp-warn-inactive t
97 "Non-nil to have \\[time-stamp] warn if a buffer did not get time-stamped.
98 A warning is printed if `time-stamp-active' disables time stamping and the
99 buffer contains a template that would otherwise have been updated."
103 (defcustom time-stamp-old-format-warn
'ask
104 "Action to take if `time-stamp-format' is an old-style list.
105 If `error', the format is not used. If `ask', the user is queried about
106 using the time-stamp-format. If `warn', a warning is displayed.
107 If 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
))
113 (defcustom time-stamp-time-zone nil
114 "If non-nil, a string naming the timezone to be used by \\[time-stamp].
115 Format is the same as that used by the environment variable TZ on your system."
116 :type
'(choice (const nil
) string
)
120 ;;; Do not change time-stamp-line-limit, time-stamp-start,
121 ;;; time-stamp-end, time-stamp-pattern, time-stamp-inserts-lines,
122 ;;; or time-stamp-count in your .emacs or you will be incompatible
123 ;;; with other people's files! If you must change them, do so only
124 ;;; in the local variables section of the file itself.
127 (defvar time-stamp-line-limit
8 ;Do not change!
128 "Lines of a file searched; positive counts from start, negative from end.
129 The patterns `time-stamp-start' and `time-stamp-end' must be found in
130 the first (last) `time-stamp-line-limit' lines of the file for the
131 file to be time-stamped by \\[time-stamp]. A value of 0 searches the
132 entire buffer (use with care).
134 Do not change `time-stamp-line-limit', `time-stamp-start', or
135 `time-stamp-end' for yourself or you will be incompatible
136 with other people's files! If you must change them for some application,
137 do so in the local variables section of the time-stamped file itself.")
140 (defvar time-stamp-start
"Time-stamp:[ \t]+\\\\?[\"<]+" ;Do not change!
141 "Regexp after which the time stamp is written by \\[time-stamp].
142 See also the variables `time-stamp-end' and `time-stamp-line-limit'.
144 Do not change `time-stamp-line-limit', `time-stamp-start', or
145 `time-stamp-end' for yourself or you will be incompatible
146 with other people's files! If you must change them for some application,
147 do so in the local variables section of the time-stamped file itself.")
150 (defvar time-stamp-end
"\\\\?[\">]" ;Do not change!
151 "Regexp marking the text after the time stamp.
152 \\[time-stamp] deletes the text between the first match of `time-stamp-start'
153 and the following match of `time-stamp-end', then writes the
154 time stamp specified by `time-stamp-format' between them.
156 The end text normally starts on the same line as the start text ends,
157 but if there are any newlines in `time-stamp-format', the same number
158 of newlines must separate the start and end. \\[time-stamp] tries
159 to not change the number of lines in the buffer. `time-stamp-inserts-lines'
160 controls this behavior.
162 Do not change `time-stamp-line-limit', `time-stamp-start', `time-stamp-end',
163 or `time-stamp-inserts-lines' for yourself or you will be incompatible
164 with other people's files! If you must change them for some application,
165 do so in the local variables section of the time-stamped file itself.")
168 (defvar time-stamp-inserts-lines nil
;Do not change!
169 "Whether time-stamp can change the number of lines in a file.
170 If nil, \\[time-stamp] skips as many lines as there are newlines in
171 `time-stamp-format' before looking for the `time-stamp-end' pattern,
172 thus it tries not to change the number of lines in the buffer.
173 If non-nil, \\[time-stamp] starts looking for the end pattern
174 immediately after the start pattern. This behavior can cause
175 unexpected changes in the buffer if used carelessly, but it is useful
176 for generating repeated time stamps.
178 Do not change `time-stamp-end' or `time-stamp-inserts-lines' for
179 yourself or you will be incompatible with other people's files!
180 If you must change them for some application, do so in the local
181 variables section of the time-stamped file itself.")
184 (defvar time-stamp-count
1 ;Do not change!
185 "How many time stamp templates \\[time-stamp] will look for in a buffer.
186 The same time-stamp will be written in each case.
188 Do not change `time-stamp-count' for yourself or you will be
189 incompatible with other people's files! If you must change it for
190 some application, do so in the local variables section of the
191 time-stamped file itself.")
194 (defvar time-stamp-pattern
"%%" ;Do not change!
195 "Convenience variable setting all `time-stamp' location and format values.
196 This string has four parts, each of which is optional.
197 These four parts set `time-stamp-line-limit', `time-stamp-start',
198 `time-stamp-format', and `time-stamp-end'. See the documentation
199 for each of these variables for details.
201 The first part is a number followed by a slash; the number sets the number
202 of lines at the beginning (negative counts from end) of the file searched
203 for the time-stamp. The number and the slash may be omitted to use the
206 The second part is a regexp identifying the pattern preceding the time stamp.
207 This part may be omitted to use the normal pattern.
209 The third part specifies the format of the time-stamp inserted. See
210 the documentation for `time-stamp-format' for details. Specify this
211 part as \"%%\" to use the normal format.
213 The fourth part is a regexp identifying the pattern following the time stamp.
214 This part may be omitted to use the normal pattern.
216 As an example, the default behavior can be specified something like this:
217 \"8/Time-stamp: [\\\"<]%:y-%02m-%02d %02H:%02M:%02S %u[\\\">]\"
219 Do not change `time-stamp-pattern' for yourself or you will be incompatible
220 with other people's files! Set it only in the local variables section
221 of the time-stamped file itself.")
227 "Update the time stamp string(s) in the buffer.
228 A template in a file can be automatically updated with a new time stamp
229 every time you save the file. Add this line to your .emacs file:
230 (add-hook 'write-file-hooks 'time-stamp)
231 Normally the template must appear in the first 8 lines of a file and
232 look like one of the following:
235 The time stamp is written between the brackets or quotes:
236 Time-stamp: <1998-02-18 10:20:51 gildea>
237 The time stamp is updated only if the variable `time-stamp-active' is non-nil.
238 The format of the time stamp is set by the variable `time-stamp-format'.
239 The variables `time-stamp-line-limit', `time-stamp-start', `time-stamp-end',
240 `time-stamp-count', and `time-stamp-inserts-lines' control finding the
243 (let ((line-limit time-stamp-line-limit
)
244 (ts-start time-stamp-start
)
245 (ts-format time-stamp-format
)
246 (ts-end time-stamp-end
)
247 (ts-count time-stamp-count
)
252 (if (stringp time-stamp-pattern
)
254 (string-match "\\`\\(\\(-?[0-9]+\\)/\\)?\\([^%]+\\)?\\(\\(.\\|\n\\)*%[-.,:@+_ #^()0-9]*[A-Za-z%]\\)?\\([^%]+\\)?\\'" time-stamp-pattern
)
255 (and (match-beginning 2)
257 (string-to-int (match-string 2 time-stamp-pattern
))))
258 (and (match-beginning 3)
259 (setq ts-start
(match-string 3 time-stamp-pattern
)))
260 (and (match-beginning 4)
261 (not (string-equal (match-string 4 time-stamp-pattern
) "%%"))
262 (setq ts-format
(match-string 4 time-stamp-pattern
)))
263 (and (match-beginning 6)
264 (setq ts-end
(match-string 6 time-stamp-pattern
)))))
265 (cond ((not (integerp line-limit
))
267 (message "time-stamp-line-limit is not an integer")
269 (cond ((not (integerp ts-count
))
271 (message "time-stamp-count is not an integer")
274 ;; We need to call time-stamp-once at least once
275 ;; to output any warnings about time-stamp not being active.
277 ;; Figure out what lines the end should be on.
279 (while (string-match "\n" ts-format nl-start
)
280 (setq format-lines
(1+ format-lines
) nl-start
(match-end 0))))
282 (while (string-match "\n" ts-end nl-start
)
283 (setq end-lines
(1+ end-lines
) nl-start
(match-end 0))))
284 ;; Find overall what lines to look at
288 (cond ((> line-limit
0)
289 (goto-char (setq start
(point-min)))
290 (forward-line line-limit
)
291 (setq search-limit
(point)))
293 (goto-char (setq search-limit
(point-max)))
294 (forward-line line-limit
)
295 (setq start
(point)))
296 (t ;0 => no limit (use with care!)
297 (setq start
(point-min))
298 (setq search-limit
(point-max))))))
300 (< start search-limit
)
302 (setq start
(time-stamp-once start search-limit ts-start ts-end
303 ts-format format-lines end-lines
))
304 (setq ts-count
(1- ts-count
))))
305 ;; be sure to return nil so can be used on write-file-hooks
308 (defun time-stamp-once (start search-limit ts-start ts-end
309 ts-format format-lines end-lines
)
310 "Update one time-stamp. Internal routine called by \\[time-stamp].
311 Returns the end point, which is where `time-stamp' begins the next search."
312 (let ((case-fold-search nil
)
319 ;; Find the location of the time stamp.
320 (while (and (< (goto-char start
) search-limit
)
322 (re-search-forward ts-start search-limit
'move
))
324 (if (not time-stamp-inserts-lines
)
325 (forward-line format-lines
))
326 (setq end-search-start
(max start
(point)))
327 (if (= (forward-line end-lines
) 0)
329 (and (bolp) (backward-char))
330 (let ((line-end (min (point) search-limit
)))
331 (if (>= line-end end-search-start
)
333 (goto-char end-search-start
)
334 (if (re-search-forward ts-end line-end t
)
336 (setq end
(match-beginning 0))
337 (setq end-length
(- (match-end 0) end
))))))))))))
340 ;; do all warnings outside save-excursion
342 ((not time-stamp-active
)
343 (if time-stamp-warn-inactive
344 ;; don't signal an error in a write-file-hook
346 (message "Warning: time-stamp-active is off; did not time-stamp buffer.")
348 ((not (and (stringp ts-start
)
350 (message "time-stamp-start or time-stamp-end is not a string")
353 (let ((new-time-stamp (time-stamp-string ts-format
)))
354 (if (and (stringp new-time-stamp
)
355 (not (string-equal (buffer-substring start end
)
360 (delete-region start end
)
362 (insert-and-inherit new-time-stamp
)
364 ;; remove any tabs used to format time stamp
365 (if (search-backward "\t" start t
)
368 (setq end
(point))))))))))))
369 ;; return the location after this time stamp, if there was one
371 (+ end end-length
))))
375 (defun time-stamp-toggle-active (&optional arg
)
376 "Toggle `time-stamp-active', setting whether \\[time-stamp] updates a buffer.
377 With arg, turn time stamping on if and only if arg is positive."
379 (setq time-stamp-active
381 (not time-stamp-active
)
382 (> (prefix-numeric-value arg
) 0)))
383 (message "time-stamp is now %s." (if time-stamp-active
"active" "off")))
386 (defun time-stamp-string (&optional ts-format
)
387 "Generate the new string to be inserted by \\[time-stamp].
388 Optionally use FORMAT."
390 (setq ts-format time-stamp-format
))
391 (if (stringp ts-format
)
392 (if (stringp time-stamp-time-zone
)
393 (let ((ts-real-time-zone (getenv "TZ")))
396 (setenv "TZ" time-stamp-time-zone
)
398 (time-stamp-string-preprocess ts-format
)))
399 (setenv "TZ" ts-real-time-zone
)))
401 (time-stamp-string-preprocess ts-format
)))
402 ;; handle version 1 compatibility
403 (cond ((or (eq time-stamp-old-format-warn
'error
)
404 (and (eq time-stamp-old-format-warn
'ask
)
405 (not (y-or-n-p "Use non-string time-stamp-format? "))))
406 (message "Warning: no time-stamp: time-stamp-format not a string")
410 (cond ((eq time-stamp-old-format-warn
'warn
)
411 (message "Obsolescent time-stamp-format type; should be string")
413 (time-stamp-fconcat ts-format
" ")))))
415 (defconst time-stamp-no-file
"(no file)"
416 "String to use when the buffer is not associated with a file.")
418 ;;; time-stamp is transitioning to using the new, expanded capabilities
419 ;;; of format-time-string. During the process, this function implements
420 ;;; intermediate, compatible formats and complains about old, soon to
421 ;;; be unsupported, formats. This function will get a lot (a LOT) shorter
422 ;;; when the transition is complete and we can just pass most things
423 ;;; straight through to format-time-string.
424 ;;; At all times, all the formats recommended in the doc string
425 ;;; of time-stamp-format will work not only in the current version of
426 ;;; Emacs, but in all versions that have been released within the past
428 ;;; The : modifier is a temporary conversion feature used to resolve
429 ;;; ambiguous formats--formats that are changing (over time) incompatibly.
430 (defun time-stamp-string-preprocess (format &optional time
)
431 ;; Use a FORMAT to format date, time, file, and user information.
432 ;; Optional second argument TIME is only for testing.
433 ;; Implements non-time extensions to format-time-string
434 ;; and all time-stamp-format compatibility.
435 (let ((fmt-len (length format
))
442 alt-form change-case require-padding
444 (while (< ind fmt-len
)
445 (setq cur-char
(aref format ind
))
451 ;; eat any additional args to allow for future expansion
452 (setq alt-form nil change-case nil require-padding nil field-width
"")
455 (setq cur-char
(if (< ind fmt-len
)
459 (eq ?
, cur-char
) (eq ?
: cur-char
) (eq ?
@ cur-char
)
460 (eq ?- cur-char
) (eq ?
+ cur-char
) (eq ?_ cur-char
)
461 (eq ?\ cur-char
) (eq ?
# cur-char
) (eq ?^ cur-char
)
462 (and (eq ?\
( cur-char
)
463 (not (eq prev-char ?
\\))
464 (setq paren-level
(1+ paren-level
)))
465 (if (and (eq ?\
) cur-char
)
466 (not (eq prev-char ?
\\))
468 (setq paren-level
(1- paren-level
))
469 (and (> paren-level
0)
471 (if (and (<= ?
0 cur-char
) (>= ?
9 cur-char
))
473 (let ((field-index ind
))
476 (setq cur-char
(if (< ind fmt-len
)
479 (and (<= ?
0 cur-char
) (>= ?
9 cur-char
))))
480 (setq field-width
(substring format field-index ind
))
483 (setq prev-char cur-char
)
484 ;; some characters we actually use
485 (cond ((eq cur-char ?
:)
488 (setq change-case t
))))
493 ((eq cur-char ?a
) ;day of week
495 (format-time-string "%#A" time
)
496 (or alt-form
(not (string-equal field-width
""))
497 (time-stamp-conv-warn "%a" "%:a"))
498 (if (and alt-form
(not (string-equal field-width
"")))
499 "" ;discourage "%:3a"
500 (format-time-string "%A" time
))))
503 (format-time-string "%A" time
)
504 (or change-case
(not (string-equal field-width
""))
505 (time-stamp-conv-warn "%A" "%#A"))
506 (format-time-string "%#A" time
)))
507 ((eq cur-char ?b
) ;month name
509 (format-time-string "%#B" time
)
510 (or alt-form
(not (string-equal field-width
""))
511 (time-stamp-conv-warn "%b" "%:b"))
512 (if (and alt-form
(not (string-equal field-width
"")))
513 "" ;discourage "%:3b"
514 (format-time-string "%B" time
))))
517 (format-time-string "%B" time
)
518 (or change-case
(not (string-equal field-width
""))
519 (time-stamp-conv-warn "%B" "%#B"))
520 (format-time-string "%#B" time
)))
521 ((eq cur-char ?d
) ;day of month, 1-31
522 (time-stamp-do-number cur-char alt-form field-width time
))
523 ((eq cur-char ?H
) ;hour, 0-23
524 (time-stamp-do-number cur-char alt-form field-width time
))
525 ((eq cur-char ?I
) ;hour, 1-12
526 (time-stamp-do-number cur-char alt-form field-width time
))
527 ((eq cur-char ?m
) ;month number, 1-12
528 (time-stamp-do-number cur-char alt-form field-width time
))
529 ((eq cur-char ?M
) ;minute, 0-59
530 (time-stamp-do-number cur-char alt-form field-width time
))
531 ((eq cur-char ?p
) ;am or pm
533 (time-stamp-conv-warn "%p" "%#p"))
534 (format-time-string "%#p" time
))
535 ((eq cur-char ?P
) ;AM or PM
536 (format-time-string "%p" time
))
537 ((eq cur-char ?S
) ;seconds, 00-60
538 (time-stamp-do-number cur-char alt-form field-width time
))
539 ((eq cur-char ?w
) ;weekday number, Sunday is 0
540 (format-time-string "%w" time
))
541 ((eq cur-char ?y
) ;year
542 (or alt-form
(not (string-equal field-width
""))
543 (time-stamp-conv-warn "%y" "%:y"))
544 (string-to-int (format-time-string "%Y" time
)))
545 ((eq cur-char ?Y
) ;4-digit year, new style
546 (string-to-int (format-time-string "%Y" time
)))
547 ((eq cur-char ?z
) ;time zone lower case
549 "" ;discourage %z variations
550 (format-time-string "%#Z" time
)))
553 (format-time-string "%#Z" time
)
554 (format-time-string "%Z" time
)))
555 ((eq cur-char ?f
) ;buffer-file-name, base name only
557 (file-name-nondirectory buffer-file-name
)
559 ((eq cur-char ?F
) ;buffer-file-name, full path
562 ((eq cur-char ?s
) ;system name
564 ((eq cur-char ?u
) ;user name
566 ((eq cur-char ?U
) ;user full name
568 ((eq cur-char ?l
) ;logname (undocumented user name alt)
570 ((eq cur-char ?L
) ;(undocumented alt user full name)
572 ((eq cur-char ?h
) ;mail host name
573 (time-stamp-mail-host-name))
575 (if (string-equal field-width
"")
578 (format (format "%%%s%c"
580 (if (numberp field-result
) ?d ?s
))
581 (or field-result
""))))
582 (let ((initial-length (length padded-result
))
583 (desired-length (string-to-int field-width
)))
584 (if (> initial-length desired-length
)
585 ;; truncate strings on right, years on left
586 (if (stringp field-result
)
587 (substring padded-result
0 desired-length
)
589 (substring padded-result
(- desired-length
))
590 padded-result
)) ;non-year numbers don't truncate
593 (char-to-string cur-char
)))))
597 (defun time-stamp-do-number (format-char alt-form field-width time
)
598 ;; Handle a compatible FORMAT-CHAR where only
599 ;; the default width/padding will change.
600 ;; ALT-FORM is whether `#' specified. FIELD-WIDTH is the string
601 ;; width specification or "". TIME is the time to convert.
602 (let ((format-string (concat "%" (char-to-string format-char
))))
603 (and (not alt-form
) (string-equal field-width
"")
604 (time-stamp-conv-warn format-string
605 (format "%%:%c" format-char
)))
606 (if (and alt-form
(not (string-equal field-width
"")))
607 "" ;discourage "%:2d" and the like
608 (string-to-int (format-time-string format-string time
)))))
610 (defvar time-stamp-conversion-warn t
611 "Non-nil to warn about soon-to-be-unsupported forms in `time-stamp-format'.
612 In would be a bad idea to disable these warnings!
613 You really need to update your files instead.
615 The new formats will work with old versions of Emacs.
616 New formats are being recommended now to allow `time-stamp-format'
617 to change in the future to be compatible with `format-time-string'.
618 The new forms being recommended now will continue to work then.")
621 (defun time-stamp-conv-warn (old-form new-form
)
622 ;; Display a warning about a soon-to-be-obsolete format.
624 (time-stamp-conversion-warn
626 (set-buffer (get-buffer-create "*Time-stamp-compatibility*"))
627 (goto-char (point-max))
631 "The formats recognized in time-stamp-format will change in a future release\n"
632 "to be compatible with the new, expanded format-time-string function.\n\n"
633 "The following obsolescent time-stamp-format construct(s) were found:\n\n")))
634 (insert "\"" old-form
"\" -- use " new-form
"\n"))
635 (display-buffer "*Time-stamp-compatibility*"))))
639 (defun time-stamp-mail-host-name ()
640 "Return the name of the host where the user receives mail.
641 This is the value of `mail-host-address' if bound and a string,
642 otherwise the value of the function `system-name'."
643 (or (and (boundp 'mail-host-address
)
644 (stringp mail-host-address
)
648 ;;; the rest of this file is for version 1 compatibility
650 (defun time-stamp-fconcat (list sep
)
651 "Similar to (mapconcat 'funcall LIST SEP) but LIST allows literals.
652 If an element of LIST is a symbol, it is funcalled to get the string to use;
653 the separator SEP is used between two strings obtained by funcalling a
654 symbol. Otherwise the element itself is inserted; no separator is used
656 (let ((return-string "")
659 (cond ((symbolp (car list
))
661 (setq return-string
(concat return-string sep
)))
662 (setq return-string
(concat return-string
(funcall (car list
))))
663 (setq insert-sep-p t
))
665 (setq return-string
(concat return-string
(car list
)))
666 (setq insert-sep-p nil
)))
667 (setq list
(cdr list
)))
670 ;;; Some functions used in time-stamp-format
672 ;;; Could generate most of a message-id with
673 ;;; '(time-stamp-yymmdd "" time-stamp-hhmm "@" time-stamp-mail-host-name)
675 ;;; pretty form, suitable for a title page
677 (defun time-stamp-month-dd-yyyy ()
678 "Return the current date as a string in \"Month DD, YYYY\" form."
679 (format-time-string "%B %e, %Y"))
681 (defun time-stamp-dd/mm
/yyyy
()
682 "Return the current date as a string in \"DD/MM/YYYY\" form."
683 (format-time-string "%d/%m/%Y"))
685 ;;; same as __DATE__ in ANSI C
687 (defun time-stamp-mon-dd-yyyy ()
688 "Return the current date as a string in \"Mon DD YYYY\" form.
689 The first character of DD is space if the value is less than 10."
690 (format-time-string "%b %d %Y"))
694 (defun time-stamp-dd-mon-yy ()
695 "Return the current date as a string in \"DD Mon YY\" form."
696 (format-time-string "%d %b %y"))
700 (defun time-stamp-yy/mm
/dd
()
701 "Return the current date as a string in \"YY/MM/DD\" form."
702 (format-time-string "%y/%m/%d"))
706 (defun time-stamp-yyyy/mm
/dd
()
707 "Return the current date as a string in \"YYYY/MM/DD\" form."
708 (format-time-string "%Y/%m/%d"))
712 (defun time-stamp-yyyy-mm-dd ()
713 "Return the current date as a string in \"YYYY-MM-DD\" form."
714 (format-time-string "%Y-%m-%d"))
716 (defun time-stamp-yymmdd ()
717 "Return the current date as a string in \"YYMMDD\" form."
718 (format-time-string "%y%m%d"))
720 (defun time-stamp-hh:mm
:ss
()
721 "Return the current time as a string in \"HH:MM:SS\" form."
722 (format-time-string "%T"))
724 (defun time-stamp-hhmm ()
725 "Return the current time as a string in \"HHMM\" form."
726 (format-time-string "%H%M"))
728 (provide 'time-stamp
)
730 ;;; time-stamp.el ends here