mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
time-stamp: revert recent change to "%04y"
* time-stamp.el (time-stamp-string-preprocess): Revert change to "%04y"
format made 2 weeks ago by commit 0e56883878 (the previous commit to
this file). Although undocumented, "%04y" was discovered to be in use
in the wild (2016) and had not issued a warning that it would change.
Add a warning that it will change.
* time-stamp-tests.el (time-stamp-test-year-2digit): add test of "%04y"
This commit is contained in:
parent
3d57c829af
commit
600bcde608
2 changed files with 12 additions and 7 deletions
|
|
@ -545,7 +545,11 @@ and all `time-stamp-format' compatibility."
|
|||
((eq cur-char ?y) ;year
|
||||
(if alt-form
|
||||
(string-to-number (time-stamp--format "%Y" time))
|
||||
(string-to-number (time-stamp--format "%y" time))))
|
||||
(if (or (string-equal field-width "")
|
||||
(<= (string-to-number field-width) 2))
|
||||
(string-to-number (time-stamp--format "%y" time))
|
||||
(time-stamp-conv-warn (format "%%%sy" field-width) "%Y")
|
||||
(string-to-number (time-stamp--format "%Y" time)))))
|
||||
((eq cur-char ?Y) ;4-digit year
|
||||
(string-to-number (time-stamp--format "%Y" time)))
|
||||
((eq cur-char ?z) ;time zone lower case
|
||||
|
|
@ -630,8 +634,7 @@ The new forms being recommended now will continue to work then.")
|
|||
|
||||
(defun time-stamp-conv-warn (old-form new-form)
|
||||
"Display a warning about a soon-to-be-obsolete format.
|
||||
Suggests replacing OLD-FORM with NEW-FORM.
|
||||
In use before 2019 changes; will be used again after those changes settle."
|
||||
Suggests replacing OLD-FORM with NEW-FORM."
|
||||
(cond
|
||||
(time-stamp-conversion-warn
|
||||
(with-current-buffer (get-buffer-create "*Time-stamp-compatibility*")
|
||||
|
|
@ -640,7 +643,7 @@ In use before 2019 changes; will be used again after those changes settle."
|
|||
(progn
|
||||
(insert
|
||||
"The formats recognized in time-stamp-format will change in a future release\n"
|
||||
"to be compatible with the new, expanded format-time-string function.\n\n"
|
||||
"to be more compatible with the format-time-string function.\n\n"
|
||||
"The following obsolescent time-stamp-format construct(s) were found:\n\n")))
|
||||
(insert "\"" old-form "\" -- use " new-form "\n"))
|
||||
(display-buffer "*Time-stamp-compatibility*"))))
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@
|
|||
(put 'with-time-stamp-test-env 'lisp-indent-hook 'defun)
|
||||
|
||||
(defmacro time-stamp-should-warn (form)
|
||||
"Similar to `should' but verifies that a format warning is generated.
|
||||
In use before 2019 changes; will be used again after those changes settle."
|
||||
"Similar to `should' but verifies that a format warning is generated."
|
||||
`(let ((warning-count 0))
|
||||
(cl-letf (((symbol-function 'time-stamp-conv-warn)
|
||||
(lambda (_old _new)
|
||||
|
|
@ -266,7 +265,10 @@ In use before 2019 changes; will be used again after those changes settle."
|
|||
(should (equal (time-stamp-string "%_y" ref-time) " 6"))
|
||||
(should (equal (time-stamp-string "%_y" ref-time2) "16"))
|
||||
(should (equal (time-stamp-string "%y" ref-time) "06"))
|
||||
(should (equal (time-stamp-string "%y" ref-time2) "16"))))
|
||||
(should (equal (time-stamp-string "%y" ref-time2) "16"))
|
||||
;; implemented since 1995, warned since 2019, will change
|
||||
(time-stamp-should-warn (equal (time-stamp-string "%04y" ref-time) "2006"))
|
||||
(time-stamp-should-warn (equal (time-stamp-string "%4y" ref-time) "2006"))))
|
||||
|
||||
(ert-deftest time-stamp-test-year-4digit ()
|
||||
"Test time-stamp format %Y."
|
||||
|
|
|
|||
Loading…
Reference in a new issue