emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 600bcde: time-stamp: revert recent change to "%04y"


From: Stephen Gildea
Subject: [Emacs-diffs] master 600bcde: time-stamp: revert recent change to "%04y"
Date: Wed, 9 Oct 2019 12:20:22 -0400 (EDT)

branch: master
commit 600bcde608479fc454e4794add84905d6337d3fa
Author: Stephen Gildea <address@hidden>
Commit: Stephen Gildea <address@hidden>

    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"
---
 lisp/time-stamp.el            | 11 +++++++----
 test/lisp/time-stamp-tests.el |  8 +++++---
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el
index 4fb28b2..284dd48 100644
--- a/lisp/time-stamp.el
+++ b/lisp/time-stamp.el
@@ -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*"))))
diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el
index 287b5f4..ace5e58 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]