org-macs: Tiny refactoring

* lisp/org-macs.el (org-parse-time-string): Refactor code.

`org-parse-time-string' does not need to handle non-Org timestamps,
like "<tomorrow>" or "<+2d>" so we remove the cond branch.
This commit is contained in:
Nicolas Goaziou 2018-07-01 23:25:56 +02:00
parent 5057e39891
commit e1884a0985
1 changed files with 13 additions and 13 deletions

View File

@ -1107,19 +1107,19 @@ NODEFAULT, hour and minute fields are nil if not given.
Throw an error if S in not a valid Org time string.
This should be a lot faster than the `parse-time-string'."
(cond ((string-match org-ts-regexp0 s)
(list 0
(when (or (match-beginning 8) (not nodefault))
(string-to-number (or (match-string 8 s) "0")))
(when (or (match-beginning 7) (not nodefault))
(string-to-number (or (match-string 7 s) "0")))
(string-to-number (match-string 4 s))
(string-to-number (match-string 3 s))
(string-to-number (match-string 2 s))
nil nil nil))
((string-match "\\`<[^>]+>\\'" s)
(decode-time (seconds-to-time (org-matcher-time s))))
(t (error "Not an Org time string: %s" s))))
(unless (string-match org-ts-regexp0 s)
(error "Not an Org time string: %s" s))
(list 0
(cond ((match-beginning 8) (string-to-number (match-string 8)))
(nodefault nil)
(t 0))
(cond ((match-beginning 7) (string-to-number (match-string 7)))
(nodefault nil)
(t 0))
(string-to-number (match-string 4 s))
(string-to-number (match-string 3 s))
(string-to-number (match-string 2 s))
nil nil nil))
(defun org-matcher-time (s)
"Interpret a time comparison value S as a floating point time.