diff --git a/doc/ChangeLog b/doc/ChangeLog index 633058c0e..46694ab54 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2010-02-26 Carsten Dominik + + * org.texi (The date/time prompt): Document that we accept dates + like month/day/year. + 2010-02-25 Carsten Dominik * org.texi (Faces for TODO keywords, Faces for TODO keywords) diff --git a/doc/org.texi b/doc/org.texi index 3633dc8cb..ef1794700 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -5046,8 +5046,10 @@ in @b{bold}. @example 3-2-5 --> 2003-02-05 +2/5/3 --> 2003-02-05 14 --> @b{2006}-@b{06}-14 12 --> @b{2006}-@b{07}-12 +2/5 --> @b{2003}-02-05 Fri --> nearest Friday (defaultdate or later) sep 15 --> @b{2006}-09-15 feb 15 --> @b{2007}-02-15 diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fd4f94001..edf582be0 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2010-02-26 Carsten Dominik + + * org.el (org-read-date-analyze): Match American-style dates, like + 5/30 or 5/13/7. Make sure cal-iso.el is loaded. Don't force he + current year when reading ISO and American dates. + 2010-02-25 Carsten Dominik * org.el (org-face-from-face-or-color): New function. diff --git a/lisp/org.el b/lisp/org.el index 1368405ec..bbc9914be 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -13428,7 +13428,7 @@ user." (let ((nowdecode (decode-time (current-time))) delta deltan deltaw deltadef year month day hour minute second wday pm h2 m2 tl wday1 - iso-year iso-weekday iso-week iso-year iso-date futurep) + iso-year iso-weekday iso-week iso-year iso-date futurep kill-year) (setq org-read-date-analyze-futurep nil) (when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans) (setq ans "+0")) @@ -13443,22 +13443,38 @@ user." ;; If yes, store the info and postpone interpreting it until the rest ;; of the parsing is done (when (string-match "\\<\\(?:\\([0-9]+\\)-\\)?[wW]\\([0-9]\\{1,2\\}\\)\\(?:-\\([0-6]\\)\\)?\\([ \t]\\|$\\)" ans) - (setq iso-year (if (match-end 1) (org-small-year-to-year (string-to-number (match-string 1 ans)))) - iso-weekday (if (match-end 3) (string-to-number (match-string 3 ans))) + (setq iso-year (if (match-end 1) + (org-small-year-to-year + (string-to-number (match-string 1 ans)))) + iso-weekday (if (match-end 3) + (string-to-number (match-string 3 ans))) iso-week (string-to-number (match-string 2 ans))) (setq ans (replace-match "" t t ans))) - ;; Help matching ISO dates with single digit month ot day, like 2006-8-11. + ;; Help matching ISO dates with single digit month or day, like 2006-8-11. (when (string-match "^ *\\(\\([0-9]+\\)-\\)?\\([0-1]?[0-9]\\)-\\([0-3]?[0-9]\\)\\([^-0-9]\\|$\\)" ans) (setq year (if (match-end 2) (string-to-number (match-string 2 ans)) - (string-to-number (format-time-string "%Y"))) + (progn (setq kill-year t) + (string-to-number (format-time-string "%Y")))) month (string-to-number (match-string 3 ans)) day (string-to-number (match-string 4 ans))) (if (< year 100) (setq year (+ 2000 year))) (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day) t nil ans))) + ;; Help matching american dates, like 5/30 or 5/30/7 + (when (string-match + "^ *\\([0-3]?[0-9]\\)/\\([0-1]?[0-9]\\)\\(/\\([0-9]+\\)\\)?\\([^/0-9]\\|$\\)" ans) + (setq year (if (match-end 4) + (string-to-number (match-string 4 ans)) + (progn (setq kill-year t) + (string-to-number (format-time-string "%Y")))) + month (string-to-number (match-string 1 ans)) + day (string-to-number (match-string 2 ans))) + (if (< year 100) (setq year (+ 2000 year))) + (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day) + t nil ans))) ;; Help matching am/pm times, because `parse-time-string' does not do that. ;; If there is a time with am/pm, and *no* time without it, we convert ;; so that matching will be successful. @@ -13504,7 +13520,7 @@ user." (nth 3 tl) (< (nth 3 tl) (nth 3 nowdecode))) (prog1 (1+ (nth 4 nowdecode)) (setq futurep t)) (nth 4 defdecode))) - year (or (nth 5 tl) + year (or (and (not kill-year) (nth 5 tl)) (if (and org-read-date-prefer-future (nth 4 tl) (< (nth 4 tl) (nth 4 nowdecode))) (prog1 (1+ (nth 5 nowdecode)) (setq futurep t)) @@ -13531,6 +13547,7 @@ user." (cond (iso-week ;; There was an iso week + (require 'cal-iso) (setq futurep nil) (setq year (or iso-year year) day (or iso-weekday wday 1)