mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-09-02 09:45:31 +00:00
Fix 'format-seconds' when all values are zero and %z is used
* lisp/calendar/time-date.el (format-seconds): Fix all-zero time. * test/lisp/calendar/time-date-tests.el (test-format-seconds): Add two new tests. (Bug#70322)
This commit is contained in:
parent
f471181129
commit
3351697080
2 changed files with 9 additions and 3 deletions
|
@ -344,8 +344,11 @@ right of \"%x\", trailing zero units are not output."
|
|||
string)
|
||||
(cond
|
||||
((string-equal spec "z")
|
||||
(setq chop-leading (and leading-zeropos
|
||||
(min leading-zeropos (match-beginning 0)))))
|
||||
(setq chop-leading
|
||||
(if leading-zeropos
|
||||
(min leading-zeropos (match-beginning 0))
|
||||
;; The entire spec is zero, get past "%z" to last 0.
|
||||
(+ 2 (match-beginning 0)))))
|
||||
((string-equal spec "x")
|
||||
(setq chop-trailing t))
|
||||
(t
|
||||
|
|
|
@ -100,7 +100,10 @@
|
|||
(should (equal (format-seconds "%hh %z%x%mm %ss" (* 60 2)) "2m"))
|
||||
(should (equal (format-seconds "%hh %z%mm %ss" (* 60 2)) "2m 0s"))
|
||||
(should (equal (format-seconds "%hh %x%mm %ss" (* 60 2)) "0h 2m"))
|
||||
(should (equal (format-seconds "%hh %x%mm %ss" 0) "0h 0m 0s")))
|
||||
(should (equal (format-seconds "%hh %x%mm %ss" 0) "0h 0m 0s"))
|
||||
;; Bug#70322
|
||||
(should (equal (format-seconds "%y %z%d %h %m %s %%" 9999999) "115 17 46 39 %"))
|
||||
(should (equal (format-seconds "%Y, %D, %H, %M, %z%S" 0) "0 seconds")))
|
||||
|
||||
(ert-deftest test-ordinal ()
|
||||
(should (equal (date-ordinal-to-time 2008 271)
|
||||
|
|
Loading…
Reference in a new issue