org-table: match either HH:MM:SS or HH:MM (instead of MM:SS).

* org-table.el (org-table-time-string-to-seconds): match
either HH:MM:SS or HH:MM (instead of MM:SS).

Thanks to Gustav Wikström for suggesting this change.
This commit is contained in:
Bastien Guerry 2011-07-24 18:19:17 +02:00
parent 88eada52a6
commit 9c5a8ab295
1 changed files with 5 additions and 4 deletions

View File

@ -3206,7 +3206,8 @@ For example: 28 -> AB."
s))
(defun org-table-time-string-to-seconds (s)
"Convert a time string into numerical duration in seconds."
"Convert a time string into numerical duration in seconds.
S is a string matching either HH:MM:SS or HH:MM."
(cond
((and (stringp s)
(string-match "\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\)" s))
@ -3217,9 +3218,9 @@ For example: 28 -> AB."
((and (stringp s)
(not (string-match org-ts-regexp-both s))
(string-match "\\([0-9]+\\):\\([0-9]+\\)" s))
(let ((min (string-to-number (match-string 1 s)))
(sec (string-to-number (match-string 2 s))))
(+ (* min 60) sec)))))
(let ((hour (string-to-number (match-string 1 s)))
(min (string-to-number (match-string 2 s))))
(+ (* hour 3600) (* min 60))))))
(defun org-table-time-seconds-to-string (secs)
"Convert a number of seconds to a time string."