     (cl-incf count)
     (when (= 0 (mod count len-secs))
       (message (make-string 40 ?─)))))
+
+;; (format-seconds "%2D %2H %2M %Z%S" sec) does something similar, but
+;; not quite.

;; Time-stamp: <2018-02-07 17:07:13 kmodi>

(defun modi/seconds-to-human-time (&optional seconds)
  "Convert SECONDS to \"DDd HHh MMm SSs\" string.

TIME is of the type (DD HH MM SS), where each of those elements
are numbers.  If INTER is non-nil, echo the time string in a
well-formatted manner instead of returning it."
              (let ((filler "    ")
                    (str ""))
                (dolist (unit '("d" "h" "m" "s"))
                  (let* ((val (car (rassoc unit time)))
                         (val-str (cond
                                   ((and (string= unit "s") ;0 seconds
                                         (= val 0)
                                         (string-match-p "\\`\\s-*\\'" str))
                                    " 0s")
                                   ((and (string= unit "s")
                                         (> val 0))
                                    (if (integerp val)
                                        (format "%2d%s" val unit)
                                      (format "%5.2f%s" val unit)))
                                   ((and val (> val 0))
                                    (format "%2d%s " val unit))
                                   (t
                                    filler))))
                    (setq str (concat str val-str))))
                ;; (message "debug: %S" time)
                (if inter
                    (message "%0.2f seconds → %s"
                             seconds
                             (string-trim (replace-regexp-in-string " +"  " " str)))
                  (string-trim-right str)))))
           (time (cond
                  ((>= sec DAY)          ;> day
                   (let* ((days (/ (floor sec) DAY))
                          (rem (- sec (* days DAY))))
                     ;; Note that (list rem) instead of just `rem' is
                     ;; being passed to the recursive call to
                     ;; `modi/seconds-to-human-time'.  This helps us
                     ;; distinguish between direct and re-entrant
                     ;; calls to this function.
                     (append (list (cons days "d")) (modi/seconds-to-human-time (list rem)))))
                  ((>= sec HOUR)         ;> hour AND < day
                   (let* ((hours (/ (floor sec) HOUR))
                          (rem (- sec (* hours HOUR))))
                     (append (list (cons hours "h")) (modi/seconds-to-human-time (list rem)))))
                  ((>= sec MINUTE)       ;> minute AND < hour
                   (let* ((mins (/ (floor sec) MINUTE))
                          (rem (- sec (* mins MINUTE))))
                     (append (list (cons mins "m")) (modi/seconds-to-human-time (list rem)))))
                  (t                    ;< minute
                   (list (cons sec "s"))))))
      ;; If `seconds' is a number and not a list, this is *not* a
      ;; recursive call.  Return the time as a string only then.  For
      ;; re-entrant executions, return the `time' list instead.
      (if (numberp seconds)
          (funcall gen-time-string time inter)
        time))))
