]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix format-seconds error in previous change
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 13 Apr 2022 13:57:24 +0000 (15:57 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 13 Apr 2022 13:57:24 +0000 (15:57 +0200)
* lisp/calendar/time-date.el (format-seconds): Fix zero elision
when using fractional seconds.

lisp/calendar/time-date.el

index 0db973ea161a36c5e41d50b848458ec317e8a3a8..ba7c48b290dc021678a83d221450d6b3291977fe 100644 (file)
@@ -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)