From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Seeger Subject: [PATCH] European date format Date: Fri, 04 Mar 2011 18:56:36 +0100 Message-ID: <87mxlawyzv.wl%jan.seeger@thenybble.de> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Fri_Mar__4_18:56:36_2011-1" Content-Transfer-Encoding: 8bit Return-path: Received: from [140.186.70.92] (port=56048 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvZEV-0004Tp-Lz for emacs-orgmode@gnu.org; Fri, 04 Mar 2011 12:56:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PvZEU-00081j-O8 for emacs-orgmode@gnu.org; Fri, 04 Mar 2011 12:56:07 -0500 Received: from thenybble.de ([83.169.39.92]:53804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PvZEU-00080j-JT for emacs-orgmode@gnu.org; Fri, 04 Mar 2011 12:56:06 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode --Multipart_Fri_Mar__4_18:56:36_2011-1 Content-Type: text/plain; charset=US-ASCII 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 --Multipart_Fri_Mar__4_18:56:36_2011-1 Content-Type: application/octet-stream; type=patch Content-Disposition: attachment; filename="org-patch.patch" Content-Transfer-Encoding: 8bit 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. --Multipart_Fri_Mar__4_18:56:36_2011-1--