Function: org-timer-hms-to-secs

org-timer-hms-to-secs is a byte-compiled function defined in org-timer.el.gz.

Signature

(org-timer-hms-to-secs HMS)

Documentation

Convert h:mm:ss (HMS) string to an integer time.

If the string starts with a minus sign, the integer will be negative.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-timer.el.gz
(defun org-timer-hms-to-secs (hms)
  "Convert h:mm:ss (HMS) string to an integer time.
If the string starts with a minus sign, the integer will be negative."
  (if (not (string-match
	    "\\([-+]?[0-9]+\\):\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)"
	    hms))
      0
    (let* ((h (string-to-number (match-string 1 hms)))
	   (m (string-to-number (match-string 2 hms)))
	   (s (string-to-number (match-string 3 hms)))
	   (sign (equal (substring (match-string 1 hms) 0 1) "-")))
      (setq h (abs h))
      (* (if sign -1 1) (+ s (* 60 (+ m (* 60 h))))))))