From ccb3891ff5446b578b9306aec0fd9c5ec3ed8e98 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 4 Sep 2018 19:14:01 -0700 Subject: Fix format-time-string bignum bug The problem can occur on 32-bit platforms with current timestamps. * src/editfns.c (disassemble_lisp_time, decode_time_components): Support seconds counts that are bignums. * test/src/editfns-tests.el (editfns-tests--have-leap-seconds): New function. (format-time-string-with-bignum-on-32-bit): New test. --- test/src/editfns-tests.el | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/src') diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index 487f3aaa666..4a840c8d7d1 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el @@ -253,6 +253,16 @@ (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" nil (concat (make-string 2048 ?X) "0"))))) +(defun editfns-tests--have-leap-seconds () + (string-equal (format-time-string "%Y-%m-%d %H:%M:%S" 78796800 t) + "1972-06-30 23:59:60")) + +(ert-deftest format-time-string-with-bignum-on-32-bit () + (should (or (string-equal + (format-time-string "%Y-%m-%d %H:%M:%S" (- (ash 1 31) 3600) t) + "2038-01-19 02:14:08") + (editfns-tests--have-leap-seconds)))) + (ert-deftest format-with-field () (should (equal (format "First argument %2$s, then %3$s, then %1$s" 1 2 3) "First argument 2, then 3, then 1")) -- cgit v1.2.3