((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
(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*")
(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*"))))
(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)
(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."