diff options
| -rw-r--r-- | doc/emacs/files.texi | 7 | ||||
| -rw-r--r-- | doc/misc/autotype.texi | 8 | ||||
| -rw-r--r-- | lisp/time-stamp.el | 48 |
3 files changed, 35 insertions, 28 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index bfa55d38701..3d5562dcc47 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi | |||
| @@ -881,9 +881,10 @@ Time-stamp: " " | |||
| 881 | @code{before-save-hook} (@pxref{Hooks}). When you save the file, this | 881 | @code{before-save-hook} (@pxref{Hooks}). When you save the file, this |
| 882 | function then automatically updates the time stamp with the current | 882 | function then automatically updates the time stamp with the current |
| 883 | date and time. You can also use the command @kbd{M-x time-stamp} to | 883 | date and time. You can also use the command @kbd{M-x time-stamp} to |
| 884 | update the time stamp manually. For other customizations, see the | 884 | update the time stamp manually. By default the time stamp is |
| 885 | Custom group @code{time-stamp}. Note that the time stamp is formatted | 885 | formatted according to your locale setting (@pxref{Environment}) and |
| 886 | according to your locale setting (@pxref{Environment}). | 886 | time zone (@pxref{Time of Day,,, elisp, The Emacs Lisp Reference |
| 887 | Manual}). For customizations, see the Custom group @code{time-stamp}. | ||
| 887 | 888 | ||
| 888 | @node Reverting | 889 | @node Reverting |
| 889 | @section Reverting a Buffer | 890 | @section Reverting a Buffer |
diff --git a/doc/misc/autotype.texi b/doc/misc/autotype.texi index 839782a3b51..6bdbd344c7a 100644 --- a/doc/misc/autotype.texi +++ b/doc/misc/autotype.texi | |||
| @@ -531,15 +531,17 @@ then @code{time-stamp} is conveniently listed as an option in the | |||
| 531 | customization buffer. | 531 | customization buffer. |
| 532 | 532 | ||
| 533 | @vindex time-stamp-active | 533 | @vindex time-stamp-active |
| 534 | @findex time-stamp-toggle-active | ||
| 534 | @vindex time-stamp-format | 535 | @vindex time-stamp-format |
| 535 | @vindex time-stamp-start | 536 | @vindex time-stamp-time-zone |
| 536 | The time stamp is updated only if the customizable variable | 537 | The time stamp is updated only if the customizable variable |
| 537 | @code{time-stamp-active} is on, which it is by default; the command | 538 | @code{time-stamp-active} is on, which it is by default; the command |
| 538 | @code{time-stamp-toggle-active} can be used to toggle it. The format of | 539 | @code{time-stamp-toggle-active} can be used to toggle it. The format of |
| 539 | the time stamp is set by the customizable variable | 540 | the time stamp is set by the customizable variables |
| 540 | @code{time-stamp-format}. | 541 | @code{time-stamp-format} and @code{time-stamp-time-zone}. |
| 541 | 542 | ||
| 542 | @vindex time-stamp-line-limit | 543 | @vindex time-stamp-line-limit |
| 544 | @vindex time-stamp-start | ||
| 543 | @vindex time-stamp-end | 545 | @vindex time-stamp-end |
| 544 | @vindex time-stamp-count | 546 | @vindex time-stamp-count |
| 545 | @vindex time-stamp-inserts-lines | 547 | @vindex time-stamp-inserts-lines |
diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el index 46c993e1f5f..dffd59010db 100644 --- a/lisp/time-stamp.el +++ b/lisp/time-stamp.el | |||
| @@ -121,9 +121,12 @@ If nil, no notification is given." | |||
| 121 | :group 'time-stamp) | 121 | :group 'time-stamp) |
| 122 | 122 | ||
| 123 | (defcustom time-stamp-time-zone nil | 123 | (defcustom time-stamp-time-zone nil |
| 124 | "If non-nil, a string naming the timezone to be used by \\[time-stamp]. | 124 | "The time zone to be used by \\[time-stamp]. |
| 125 | Format is the same as that used by the environment variable TZ on your system." | 125 | Its format is that of the ZONE argument of the `format-time-string' function," |
| 126 | :type '(choice (const nil) string) | 126 | :type '(choice (const :tag "Emacs local time" nil) |
| 127 | (const :tag "Universal Time" t) | ||
| 128 | (const :tag "system wall clock time" wall) | ||
| 129 | (string :tag "TZ environment variable value")) | ||
| 127 | :group 'time-stamp | 130 | :group 'time-stamp |
| 128 | :version "20.1") | 131 | :version "20.1") |
| 129 | ;;;###autoload(put 'time-stamp-time-zone 'safe-local-variable 'string-or-null-p) | 132 | ;;;###autoload(put 'time-stamp-time-zone 'safe-local-variable 'string-or-null-p) |
| @@ -412,6 +415,8 @@ With ARG, turn time stamping on if and only if arg is positive." | |||
| 412 | (> (prefix-numeric-value arg) 0))) | 415 | (> (prefix-numeric-value arg) 0))) |
| 413 | (message "time-stamp is now %s." (if time-stamp-active "active" "off"))) | 416 | (message "time-stamp is now %s." (if time-stamp-active "active" "off"))) |
| 414 | 417 | ||
| 418 | (defun time-stamp--format (format time) | ||
| 419 | (format-time-string format time time-stamp-time-zone)) | ||
| 415 | 420 | ||
| 416 | (defun time-stamp-string (&optional ts-format) | 421 | (defun time-stamp-string (&optional ts-format) |
| 417 | "Generate the new string to be inserted by \\[time-stamp]. | 422 | "Generate the new string to be inserted by \\[time-stamp]. |
| @@ -420,8 +425,7 @@ format the string." | |||
| 420 | (or ts-format | 425 | (or ts-format |
| 421 | (setq ts-format time-stamp-format)) | 426 | (setq ts-format time-stamp-format)) |
| 422 | (if (stringp ts-format) | 427 | (if (stringp ts-format) |
| 423 | (format-time-string (time-stamp-string-preprocess ts-format) | 428 | (time-stamp--format (time-stamp-string-preprocess ts-format) nil) |
| 424 | nil time-stamp-time-zone) | ||
| 425 | ;; handle version 1 compatibility | 429 | ;; handle version 1 compatibility |
| 426 | (cond ((or (eq time-stamp-old-format-warn 'error) | 430 | (cond ((or (eq time-stamp-old-format-warn 'error) |
| 427 | (and (eq time-stamp-old-format-warn 'ask) | 431 | (and (eq time-stamp-old-format-warn 'ask) |
| @@ -515,32 +519,32 @@ and all `time-stamp-format' compatibility." | |||
| 515 | "%%") | 519 | "%%") |
| 516 | ((eq cur-char ?a) ;day of week | 520 | ((eq cur-char ?a) ;day of week |
| 517 | (if change-case | 521 | (if change-case |
| 518 | (format-time-string "%#a" time) | 522 | (time-stamp--format "%#a" time) |
| 519 | (or alt-form (not (string-equal field-width "")) | 523 | (or alt-form (not (string-equal field-width "")) |
| 520 | (time-stamp-conv-warn "%a" "%:a")) | 524 | (time-stamp-conv-warn "%a" "%:a")) |
| 521 | (if (and alt-form (not (string-equal field-width ""))) | 525 | (if (and alt-form (not (string-equal field-width ""))) |
| 522 | "" ;discourage "%:3a" | 526 | "" ;discourage "%:3a" |
| 523 | (format-time-string "%A" time)))) | 527 | (time-stamp--format "%A" time)))) |
| 524 | ((eq cur-char ?A) | 528 | ((eq cur-char ?A) |
| 525 | (if alt-form | 529 | (if alt-form |
| 526 | (format-time-string "%A" time) | 530 | (time-stamp--format "%A" time) |
| 527 | (or change-case (not (string-equal field-width "")) | 531 | (or change-case (not (string-equal field-width "")) |
| 528 | (time-stamp-conv-warn "%A" "%#A")) | 532 | (time-stamp-conv-warn "%A" "%#A")) |
| 529 | (format-time-string "%#A" time))) | 533 | (time-stamp--format "%#A" time))) |
| 530 | ((eq cur-char ?b) ;month name | 534 | ((eq cur-char ?b) ;month name |
| 531 | (if change-case | 535 | (if change-case |
| 532 | (format-time-string "%#b" time) | 536 | (time-stamp--format "%#b" time) |
| 533 | (or alt-form (not (string-equal field-width "")) | 537 | (or alt-form (not (string-equal field-width "")) |
| 534 | (time-stamp-conv-warn "%b" "%:b")) | 538 | (time-stamp-conv-warn "%b" "%:b")) |
| 535 | (if (and alt-form (not (string-equal field-width ""))) | 539 | (if (and alt-form (not (string-equal field-width ""))) |
| 536 | "" ;discourage "%:3b" | 540 | "" ;discourage "%:3b" |
| 537 | (format-time-string "%B" time)))) | 541 | (time-stamp--format "%B" time)))) |
| 538 | ((eq cur-char ?B) | 542 | ((eq cur-char ?B) |
| 539 | (if alt-form | 543 | (if alt-form |
| 540 | (format-time-string "%B" time) | 544 | (time-stamp--format "%B" time) |
| 541 | (or change-case (not (string-equal field-width "")) | 545 | (or change-case (not (string-equal field-width "")) |
| 542 | (time-stamp-conv-warn "%B" "%#B")) | 546 | (time-stamp-conv-warn "%B" "%#B")) |
| 543 | (format-time-string "%#B" time))) | 547 | (time-stamp--format "%#B" time))) |
| 544 | ((eq cur-char ?d) ;day of month, 1-31 | 548 | ((eq cur-char ?d) ;day of month, 1-31 |
| 545 | (time-stamp-do-number cur-char alt-form field-width time)) | 549 | (time-stamp-do-number cur-char alt-form field-width time)) |
| 546 | ((eq cur-char ?H) ;hour, 0-23 | 550 | ((eq cur-char ?H) ;hour, 0-23 |
| @@ -554,27 +558,27 @@ and all `time-stamp-format' compatibility." | |||
| 554 | ((eq cur-char ?p) ;am or pm | 558 | ((eq cur-char ?p) ;am or pm |
| 555 | (or change-case | 559 | (or change-case |
| 556 | (time-stamp-conv-warn "%p" "%#p")) | 560 | (time-stamp-conv-warn "%p" "%#p")) |
| 557 | (format-time-string "%#p" time)) | 561 | (time-stamp--format "%#p" time)) |
| 558 | ((eq cur-char ?P) ;AM or PM | 562 | ((eq cur-char ?P) ;AM or PM |
| 559 | (format-time-string "%p" time)) | 563 | (time-stamp--format "%p" time)) |
| 560 | ((eq cur-char ?S) ;seconds, 00-60 | 564 | ((eq cur-char ?S) ;seconds, 00-60 |
| 561 | (time-stamp-do-number cur-char alt-form field-width time)) | 565 | (time-stamp-do-number cur-char alt-form field-width time)) |
| 562 | ((eq cur-char ?w) ;weekday number, Sunday is 0 | 566 | ((eq cur-char ?w) ;weekday number, Sunday is 0 |
| 563 | (format-time-string "%w" time)) | 567 | (time-stamp--format "%w" time)) |
| 564 | ((eq cur-char ?y) ;year | 568 | ((eq cur-char ?y) ;year |
| 565 | (or alt-form (not (string-equal field-width "")) | 569 | (or alt-form (not (string-equal field-width "")) |
| 566 | (time-stamp-conv-warn "%y" "%:y")) | 570 | (time-stamp-conv-warn "%y" "%:y")) |
| 567 | (string-to-number (format-time-string "%Y" time))) | 571 | (string-to-number (time-stamp--format "%Y" time))) |
| 568 | ((eq cur-char ?Y) ;4-digit year, new style | 572 | ((eq cur-char ?Y) ;4-digit year, new style |
| 569 | (string-to-number (format-time-string "%Y" time))) | 573 | (string-to-number (time-stamp--format "%Y" time))) |
| 570 | ((eq cur-char ?z) ;time zone lower case | 574 | ((eq cur-char ?z) ;time zone lower case |
| 571 | (if change-case | 575 | (if change-case |
| 572 | "" ;discourage %z variations | 576 | "" ;discourage %z variations |
| 573 | (format-time-string "%#Z" time))) | 577 | (time-stamp--format "%#Z" time))) |
| 574 | ((eq cur-char ?Z) | 578 | ((eq cur-char ?Z) |
| 575 | (if change-case | 579 | (if change-case |
| 576 | (format-time-string "%#Z" time) | 580 | (time-stamp--format "%#Z" time) |
| 577 | (format-time-string "%Z" time))) | 581 | (time-stamp--format "%Z" time))) |
| 578 | ((eq cur-char ?f) ;buffer-file-name, base name only | 582 | ((eq cur-char ?f) ;buffer-file-name, base name only |
| 579 | (if buffer-file-name | 583 | (if buffer-file-name |
| 580 | (file-name-nondirectory buffer-file-name) | 584 | (file-name-nondirectory buffer-file-name) |
| @@ -634,7 +638,7 @@ width specification or \"\". TIME is the time to convert." | |||
| 634 | (format "%%:%c" format-char))) | 638 | (format "%%:%c" format-char))) |
| 635 | (if (and alt-form (not (string-equal field-width ""))) | 639 | (if (and alt-form (not (string-equal field-width ""))) |
| 636 | "" ;discourage "%:2d" and the like | 640 | "" ;discourage "%:2d" and the like |
| 637 | (string-to-number (format-time-string format-string time))))) | 641 | (string-to-number (time-stamp--format format-string time))))) |
| 638 | 642 | ||
| 639 | (defvar time-stamp-conversion-warn t | 643 | (defvar time-stamp-conversion-warn t |
| 640 | "Warn about soon-to-be-unsupported forms in `time-stamp-format'. | 644 | "Warn about soon-to-be-unsupported forms in `time-stamp-format'. |