]> git.eshelyaron.com Git - emacs.git/commitdiff
time-stamp: revert recent change to "%04y"
authorStephen Gildea <stepheng+git-config-global@gildea.com>
Wed, 9 Oct 2019 16:19:10 +0000 (09:19 -0700)
committerStephen Gildea <stepheng+git-config-global@gildea.com>
Wed, 9 Oct 2019 16:19:10 +0000 (09:19 -0700)
* 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"

lisp/time-stamp.el
test/lisp/time-stamp-tests.el

index 4fb28b2fd376d08fbb3079e107f4842331259016..284dd48d4fcb9aa9e9b550926e9fa8ee176a4de4 100644 (file)
@@ -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*"))))
index 287b5f486c3d2b2768260b411b847a0fd75b49d7..ace5e58e367bebb0a2b27cc20db51eb793e70684 100644 (file)
@@ -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."