Function: eca-jobs--elapsed-since

eca-jobs--elapsed-since is a natively compiled function defined in eca-jobs.el.

Signature

(eca-jobs--elapsed-since STARTED-AT)

Documentation

Compute human-readable elapsed time from STARTED-AT ISO 8601 string.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-jobs.el
;; Helpers

(defun eca-jobs--elapsed-since (started-at)
  "Compute human-readable elapsed time from STARTED-AT ISO 8601 string."
  (when (and started-at (stringp started-at)
             (string-match
              "\\`\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)T\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)"
              started-at))
    (let* ((start (encode-time
                   (list (string-to-number (match-string 6 started-at))
                         (string-to-number (match-string 5 started-at))
                         (string-to-number (match-string 4 started-at))
                         (string-to-number (match-string 3 started-at))
                         (string-to-number (match-string 2 started-at))
                         (string-to-number (match-string 1 started-at))
                         nil nil 0)))
           (secs (floor (float-time (time-subtract nil start)))))
      (cond
       ((< secs 60) (format "%ds" secs))
       ((< secs 3600) (format "%dm%ds" (/ secs 60) (mod secs 60)))
       (t (format "%dh%dm" (/ secs 3600) (mod (/ secs 60) 60)))))))