summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-11-15 21:02:26 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2012-11-15 21:02:26 +0100
commitb46b5d1c44017d44b68c88fdc0669becd03af4e0 (patch)
tree6fb7bfd691a89df7962c8fdaf5cd03ed613939fb
parentaa7dbec775c5b757f1cd7b7afb3605e8e722cd6a (diff)
downloadorg-mode-b46b5d1c44017d44b68c88fdc0669becd03af4e0.tar.gz
org-element: Return nil for unspecified time values
* lisp/org-element.el (org-element-timestamp-parser): Return nil for unspecified :hour-end and :minute-end properties. * testing/lisp/test-org-element.el: Add tests.
-rw-r--r--lisp/org-element.el9
-rw-r--r--testing/lisp/test-org-element.el22
2 files changed, 20 insertions, 11 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index a8b6cad..933a706 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3449,7 +3449,6 @@ Assume point is at the beginning of the timestamp."
(post-blank (progn (goto-char (match-end 0))
(skip-chars-forward " \t")))
(end (point))
- (with-time-p (string-match "[012]?[0-9]:[0-5][0-9]" date-start))
(repeater-props
(and (not diaryp)
(string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)>"
@@ -3478,17 +3477,17 @@ Assume point is at the beginning of the timestamp."
(setq date-start (replace-match "" nil nil date-start 1)))
;; Parse date-start.
(unless diaryp
- (let ((date (org-parse-time-string date-start)))
+ (let ((date (org-parse-time-string date-start t)))
(setq year-start (nth 5 date)
month-start (nth 4 date)
day-start (nth 3 date)
- hour-start (and with-time-p (nth 2 date))
- minute-start (and with-time-p (nth 1 date)))))
+ hour-start (nth 2 date)
+ minute-start (nth 1 date))))
;; Compute date-end. It can be provided directly in time-stamp,
;; or extracted from time range. Otherwise, it defaults to the
;; same values as date-start.
(unless diaryp
- (let ((date (and date-end (org-parse-time-string date-end))))
+ (let ((date (and date-end (org-parse-time-string date-end t))))
(setq year-end (or (nth 5 date) year-start)
month-end (or (nth 4 date) month-start)
day-end (or (nth 3 date) day-start)
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index d6298db..e991f80 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1718,9 +1718,14 @@ Outside list"
(should
(org-test-with-temp-text "<2012-03-29 16:40>"
(eq (org-element-property :type (org-element-context)) 'active)))
+ (should-not
+ (org-test-with-temp-text "<2012-03-29 Thu.>"
+ (let ((timestamp (org-element-context)))
+ (or (org-element-property :hour-start timestamp)
+ (org-element-property :minute-start timestamp)))))
(should
(equal '(2012 3 29 16 40)
- (org-test-with-temp-text "<2012-03-29 16:40>"
+ (org-test-with-temp-text "<2012-03-29 Thu. 16:40>"
(let ((object (org-element-context)))
(list (org-element-property :year-start object)
(org-element-property :month-start object)
@@ -1729,12 +1734,12 @@ Outside list"
(org-element-property :minute-start object))))))
;; Inactive timestamp.
(should
- (org-test-with-temp-text "[2012-03-29 16:40]"
+ (org-test-with-temp-text "[2012-03-29 Thu. 16:40]"
(eq (org-element-property :type (org-element-context)) 'inactive)))
;; Time range.
(should
(equal '(2012 3 29 16 40 7 30)
- (org-test-with-temp-text "<2012-03-29 7:30-16:40>"
+ (org-test-with-temp-text "<2012-03-29 Thu. 7:30-16:40>"
(let ((object (org-element-context)))
(list (org-element-property :year-end object)
(org-element-property :month-end object)
@@ -1745,16 +1750,21 @@ Outside list"
(org-element-property :minute-start object))))))
;; Date range.
(should
- (org-test-with-temp-text "[2012-03-29 16:40]--[2012-03-29 16:41]"
+ (org-test-with-temp-text "[2012-03-29 Thu. 16:40]--[2012-03-29 Thu. 16:41]"
(eq (org-element-property :type (org-element-context)) 'inactive-range)))
+ (should-not
+ (org-test-with-temp-text "[2011-07-14 Thu.]--[2012-03-29 Thu.]"
+ (let ((timestamp (org-element-context)))
+ (or (org-element-property :hour-end timestamp)
+ (org-element-property :minute-end timestamp)))))
;; With repeater.
(should
(eq 'catch-up
- (org-test-with-temp-text "<2012-03-29 ++1y>"
+ (org-test-with-temp-text "<2012-03-29 Thu. ++1y>"
(org-element-property :repeater-type (org-element-context)))))
;; Timestamps are not planning elements.
(should-not
- (org-test-with-temp-text "SCHEDULED: <2012-03-29 16:40>"
+ (org-test-with-temp-text "SCHEDULED: <2012-03-29 Thu. 16:40>"
(org-element-map (org-element-parse-buffer) 'timestamp 'identity))))