emacs-diffs
[Top][All Lists]
Advanced

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

master a5b57fc: time-stamp: fix minor bug when parsing option combos


From: Stephen Gildea
Subject: master a5b57fc: time-stamp: fix minor bug when parsing option combos
Date: Sun, 30 May 2021 14:07:18 -0400 (EDT)

branch: master
commit a5b57fc6af7ec87c59d00a7631576f9f4bf99841
Author: Stephen Gildea <stepheng+emacs@gildea.com>
Commit: Stephen Gildea <stepheng+emacs@gildea.com>

    time-stamp: fix minor bug when parsing option combos
    
    * lisp/time-stamp.el (time-stamp-string-preprocess): Handle digit
    options correctly to avoid overcounting colon options.
    
    * test/lisp/time-stamp-tests.el (time-stamp-format-time-zone-offset):
    Add a new test case that would have caught the option-parsing error.
---
 lisp/time-stamp.el            | 4 +++-
 test/lisp/time-stamp-tests.el | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el
index 42455dd..0cc566f 100644
--- a/lisp/time-stamp.el
+++ b/lisp/time-stamp.el
@@ -499,7 +499,8 @@ and all `time-stamp-format' compatibility."
                                (< ind fmt-len)))
                         (if (and (<= ?0 cur-char) (>= ?9 cur-char))
                             ;; get format width
-                            (let ((field-index ind))
+                            (let ((field-index ind)
+                                  (first-digit cur-char))
                               (while (progn
                                        (setq ind (1+ ind))
                                        (setq cur-char (if (< ind fmt-len)
@@ -510,6 +511,7 @@ and all `time-stamp-format' compatibility."
                               (setq field-width
                                     (substring format field-index ind))
                               (setq ind (1- ind))
+                              (setq cur-char first-digit)
                               t))))
              (setq prev-char cur-char)
              ;; some characters we actually use
diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el
index c021353..b42271e 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -525,7 +525,7 @@
       (should (equal (time-stamp-string "%#Z" ref-time1) utc-abbr)))))
 
 (ert-deftest time-stamp-format-time-zone-offset ()
-  "Test time-stamp format %z."
+  "Tests time-stamp legacy format %z and new offset format %5z."
   (with-time-stamp-test-env
     (let ((utc-abbr (format-time-string "%#Z" ref-time1 t)))
     ;; documented 1995-2019, warned since 2019, will change
@@ -544,6 +544,7 @@
     (should (equal (time-stamp-string "%_z" ref-time1) "+0000"))
     (should (equal (time-stamp-string "%:z" ref-time1) "+00:00"))
     (should (equal (time-stamp-string "%::z" ref-time1) "+00:00:00"))
+    (should (equal (time-stamp-string "%9::z" ref-time1) "+00:00:00"))
     (should (equal (time-stamp-string "%:::z" ref-time1) "+00"))))
 
 (ert-deftest time-stamp-format-non-date-conversions ()



reply via email to

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