summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2010-06-04 12:29:31 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2010-06-04 12:35:41 +0200
commit420dd96768262cb15c8bcf4fa6386361e0327add (patch)
treeaa674f49fdf837452d01336a7d1ad92a487765b3
parent6bad6fc737e4a081ed2c9828195e9b65125846a0 (diff)
downloadorg-mode-420dd96768262cb15c8bcf4fa6386361e0327add.tar.gz
Fix the date prompt for american-style dates
* lisp/org.el (org-read-date-analyze): Fix regular expression for matching american dates Daniel E. Doherty writes: > In playing around with the date prompt (C-.), I ran across the following > puzzling behavior from rather simple inputs. > > I entered the following on June 1, 2010. Here is a date entered as > "3/15": <2011-03-15 Tue>. It interpreted it as the upcoming March 15 as > expected. > > But here is a date entered as "5/21": <2021-06-05 Sat>. Note how it > interpreted the "21" as the year 2021, not at all what I expected from > the documentation or the analogous "3/15" example. > > Maybe there is some underlying logic here that I'm not getting. Perhaps > it has to do with how 2-digit years are interpreted? > > What's going on here? I am using org-version 6.36trans on emacs 23.1. What was going on here is that the regular expression for matching american-style dates was wrong. It was looking for month numbers in the second field and day numbers in the first field - wrong, of course.
-rw-r--r--lisp/org.el11
1 files changed, 8 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 64044b4..48fd215 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13942,10 +13942,15 @@ The prompt will suggest to enter an ISO date, but you can also enter anything
which will at least partially be understood by `parse-time-string'.
Unrecognized parts of the date will default to the current day, month, year,
hour and minute. If this command is called to replace a timestamp at point,
-of to enter the second timestamp of a range, the default time is taken from the
-existing stamp. For example,
+of to enter the second timestamp of a range, the default time is taken
+from the existing stamp. Furthermore, the command prefers the future,
+so if you are giving a date where the year is not given, and the day-month
+combination is already past in the current year, it will assume you
+mean next year. For details, see the manual. A few examples:
+
3-2-5 --> 2003-02-05
feb 15 --> currentyear-02-15
+ 2/15 --> currentyear-02-15
sep 12 9 --> 2009-09-12
12:45 --> today 12:45
22 sept 0:34 --> currentyear-09-22 0:34
@@ -14191,7 +14196,7 @@ user."
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)
+ "^ *\\(0?[1-9]\\|1[012]\\)/\\(0?[1-9]\\|[12][0-9]\\|3[01]\\)\\(/\\([0-9]+\\)\\)?\\([^/0-9]\\|$\\)" ans)
(setq year (if (match-end 4)
(string-to-number (match-string 4 ans))
(progn (setq kill-year t)