all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] European date format
@ 2011-03-04 17:56 Jan Seeger
  2011-03-04 19:04 ` Nick Dokos
  2011-04-08 10:06 ` Carsten Dominik
  0 siblings, 2 replies; 10+ messages in thread
From: Jan Seeger @ 2011-03-04 17:56 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 217 bytes --]

Greetings!

I was annoyed that org only read the bassackwards american date
format, and implemented european date format matching. I hope it's
correct, it seems to work for dates with and without year.

Regards,
Jan


[-- Attachment #2: org-patch.patch --]
[-- Type: application/octet-stream, Size: 1010 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index 3a07cfd..fa54d4e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14584,6 +14584,17 @@ user."
       (if (< year 100) (setq year (+ 2000 year)))
       (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day)
 			       t nil ans)))
+    ;; European date match
+    (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"))))
+	    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)
+				     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.

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-04-08 10:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-04 17:56 [PATCH] European date format Jan Seeger
2011-03-04 19:04 ` Nick Dokos
2011-03-04 19:11   ` Jan Seeger
2011-03-04 19:46     ` Nick Dokos
2011-03-04 21:13       ` Milan Zamazal
2011-03-04 21:21         ` Nick Dokos
2011-03-04 21:38           ` Michael Radziej
2011-03-04 23:11         ` Sébastien Vauban
2011-03-05  7:45   ` Achim Gratz
2011-04-08 10:06 ` Carsten Dominik

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.