aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/time-stamp.el48
1 files changed, 26 insertions, 22 deletions
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].
125Format is the same as that used by the environment variable TZ on your system." 125Its 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'.