]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix format-time-string %Z bug with negative tz
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 18 Sep 2017 03:38:12 +0000 (20:38 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 18 Sep 2017 03:39:12 +0000 (20:39 -0700)
* 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
test/src/editfns-tests.el

index b03eb947dec61dda1670dadca7cc292ca326a7ab..2f8b075817abff6fd750a88f5a6015c3f54fcdb5 100644 (file)
@@ -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;
            }
index 1c3fde888f6d708fe73b2707d37a50788332fbc3..f910afaf7118f68de6f48f8d3ef4b72dd1f2dd47 100644 (file)
     (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")