emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-26 541006c: Fix format-time-string %Z bug with negat


From: Paul Eggert
Subject: [Emacs-diffs] emacs-26 541006c: Fix format-time-string %Z bug with negative tz
Date: Sun, 17 Sep 2017 23:39:18 -0400 (EDT)

branch: emacs-26
commit 541006c53623cb5fb7dfae475baae5d64fc6e9d0
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Fix format-time-string %Z bug with negative tz
    
    * src/editfns.c (tzlookup): Fix sign error in %Z when a purely
    numeric zone is negative (Bug#28746).
    * test/src/editfns-tests.el (format-time-string-with-zone):
    Add test for this bug.
---
 src/editfns.c             | 3 ++-
 test/src/editfns-tests.el | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/editfns.c b/src/editfns.c
index b03eb94..2f8b075 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -187,7 +187,8 @@ tzlookup (Lisp_Object zone, bool settz)
                  if (sec != 0)
                    prec += 2, numzone = 100 * numzone + sec;
                }
-             sprintf (tzbuf, tzbuf_format, prec, numzone,
+             sprintf (tzbuf, tzbuf_format, prec,
+                      XINT (zone) < 0 ? -numzone : numzone,
                       &"-"[XINT (zone) < 0], hour, min, sec);
              zone_string = tzbuf;
            }
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index 1c3fde8..f910afa 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -166,6 +166,10 @@
     (should (string-equal
              (format-time-string format look '(-28800 "PST"))
              "1972-06-30 15:59:59.999 -0800 (PST)"))
+    ;; Negative UTC offset, as a Lisp integer.
+    (should (string-equal
+             (format-time-string format look -28800)
+             "1972-06-30 15:59:59.999 -0800 (-08)"))
     ;; Positive UTC offset that is not an hour multiple, as a string.
     (should (string-equal
              (format-time-string format look "IST-5:30")



reply via email to

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