summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-10-12 17:52:47 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2012-10-12 18:17:25 +0200
commit5212d4fa6bb0039f6cfc5166f02be57106ee7e16 (patch)
treec774a1b249e60f3f3033bf897705ea7a5b71fe77
parent93f4b7c6d854e34d77632492588dd44526f44989 (diff)
downloadorg-mode-5212d4fa6bb0039f6cfc5166f02be57106ee7e16.tar.gz
Fix analyzing european dates with time but without year
* lisp/org.el (org-read-date-analyze): Fix analyzing for dates like "29.03 16:40". * testing/lisp/test-org.el: Add test.
-rw-r--r--lisp/org.el11
-rw-r--r--testing/lisp/test-org.el19
2 files changed, 24 insertions, 6 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 59683bc..1fd3f76 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15502,14 +15502,13 @@ user."
;; Help matching dotted european dates
(when (string-match
- "^ *\\(3[01]\\|0?[1-9]\\|[12][0-9]\\)\\. ?\\(0?[1-9]\\|1[012]\\)\\. ?\\([1-9][0-9][0-9][0-9]\\)?" ans)
- (setq year (if (match-end 3)
- (string-to-number (match-string 3 ans))
- (progn (setq kill-year t)
- (string-to-number (format-time-string "%Y"))))
+ "^ *\\(3[01]\\|0?[1-9]\\|[12][0-9]\\)\\. ?\\(0?[1-9]\\|1[012]\\)\\.\\( ?[1-9][0-9]\\{3\\}\\)?" ans)
+ (setq year (if (match-end 3) (string-to-number (match-string 3 ans))
+ (setq kill-year t)
+ (string-to-number (format-time-string "%Y")))
day (string-to-number (match-string 1 ans))
month (string-to-number (match-string 2 ans))
- ans (replace-match (format "%04d-%02d-%02d\\5" year month day)
+ ans (replace-match (format "%04d-%02d-%02d" year month day)
t nil ans)))
;; Help matching american dates, like 5/30 or 5/30/7
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 7519ed2..feb0f2a 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -90,6 +90,25 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
+;;; Date Analysis
+
+(ert-deftest test-org/org-read-date ()
+ "Test `org-read-date' specifications."
+ ;; Parse ISO date with abbreviated year and month.
+ (should (equal "2012-03-29 16:40"
+ (let ((org-time-was-given t))
+ (org-read-date t nil "12-3-29 16:40"))))
+ ;; Parse Europeans dates.
+ (should (equal "2012-03-29 16:40"
+ (let ((org-time-was-given t))
+ (org-read-date t nil "29.03.2012 16:40"))))
+ ;; Parse Europeans dates without year.
+ (should (string-match "2[0-9]\\{3\\}-03-29 16:40"
+ (let ((org-time-was-given t))
+ (org-read-date t nil "29.03. 16:40")))))
+
+
+
;;; Links
;;;; Fuzzy links