From 0ef9f6d07b5abe60005bea3eb2bb6d9c3aafbb98 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 13 Apr 2022 15:57:24 +0200 Subject: [PATCH] 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 0db973ea161..ba7c48b290d 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) -- 2.39.5