Function: org-get-compact-tod
org-get-compact-tod is a byte-compiled function defined in org.el.gz.
Signature
(org-get-compact-tod S)
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
;; FIXME: can we use this for something else, like computing time differences?
(defun org-get-compact-tod (s)
(when (string-match "\\(\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)\\(-\\(\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)\\)?" s)
(let* ((t1 (match-string 1 s))
(h1 (string-to-number (match-string 2 s)))
(m1 (string-to-number (match-string 3 s)))
(t2 (and (match-end 4) (match-string 5 s)))
(h2 (and t2 (string-to-number (match-string 6 s))))
(m2 (and t2 (string-to-number (match-string 7 s))))
dh dm)
(if (not t2)
t1
(setq dh (- h2 h1) dm (- m2 m1))
(when (< dm 0) (setq dm (+ dm 60) dh (1- dh)))
(concat t1 "+" (number-to-string dh)
(and (/= 0 dm) (format ":%02d" dm)))))))