[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0ef9f6d07b: Fix format-seconds error in previous change
From: |
Lars Ingebrigtsen |
Subject: |
master 0ef9f6d07b: Fix format-seconds error in previous change |
Date: |
Wed, 13 Apr 2022 09:57:37 -0400 (EDT) |
branch: master
commit 0ef9f6d07b5abe60005bea3eb2bb6d9c3aafbb98
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix format-seconds error in previous change
* lisp/calendar/time-date.el (format-seconds): Fix zero elision
when using fractional seconds.
---
lisp/calendar/time-date.el | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index 0db973ea16..ba7c48b290 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -343,15 +343,18 @@ right of \"%x\", trailing zero units are not output."
;; Cf article-make-date-line in gnus-art.
(setq num (floor seconds unit)
seconds (- seconds (* num unit)))
- ;; Start position of the first non-zero unit.
- (when (and (not leading-zeropos)
- (not (zerop num)))
- (setq leading-zeropos (match-beginning 0)))
- (unless (zerop num)
- (setq trailing-zeropos nil))
- (when (and (not trailing-zeropos)
- (zerop num))
- (setq trailing-zeropos (match-beginning 0)))
+ (let ((is-zero (zerop (if (= unit 1)
+ (+ num fraction)
+ num))))
+ ;; Start position of the first non-zero unit.
+ (when (and (not leading-zeropos)
+ (not is-zero))
+ (setq leading-zeropos (match-beginning 0)))
+ (unless is-zero
+ (setq trailing-zeropos nil))
+ (when (and (not trailing-zeropos)
+ is-zero)
+ (setq trailing-zeropos (match-beginning 0))))
(setq string
(replace-match
(format (if (match-string 2 string)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 0ef9f6d07b: Fix format-seconds error in previous change,
Lars Ingebrigtsen <=