From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: [PATCH] European date format Date: Fri, 04 Mar 2011 14:04:42 -0500 Message-ID: <3695.1299265482@alphaville.usa.hp.com> References: <87mxlawyzv.wl%jan.seeger@thenybble.de> Reply-To: nicholas.dokos@hp.com Return-path: Received: from [140.186.70.92] (port=51620 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvaIz-0003y8-OQ for emacs-orgmode@gnu.org; Fri, 04 Mar 2011 14:04:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PvaIv-0005tw-5j for emacs-orgmode@gnu.org; Fri, 04 Mar 2011 14:04:49 -0500 Received: from g4t0016.houston.hp.com ([15.201.24.19]:35656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PvaIu-0005tf-Vf for emacs-orgmode@gnu.org; Fri, 04 Mar 2011 14:04:45 -0500 In-Reply-To: Message from Jan Seeger of "Fri, 04 Mar 2011 18:56:36 +0100." <87mxlawyzv.wl%jan.seeger@thenybble.de> 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: Jan Seeger Cc: nicholas.dokos@hp.com, emacs-orgmode Jan Seeger wrote: > 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. > It would help if you provided a few examples of what "European format" is. Deciphering long regexps is maybe fun the first time you do it, but after that it quickly loses its charm :-) BTW, if you (and I don't just mean Jan here) haven't tried re-builder, you should: add a few strings to a buffer, M-x re-builder and type in the regexp. It interactively and incrementally shows what matches. In any case, I tried to decipher your regexp and it seems to me that there is at least one (small) problem: a date without a year won't match without a final period. E.g. 4.3. ==> the fourth day of March, 2011 4.3 ==> does not match Thanks, Nick PS. Also, patches are just text, so please include them in the mail (or at least make sure that they are attached as text/plain or something similar, rather than application/octet-stream). Here's the patch for reference: --8<---------------cut here---------------start------------->8--- 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. --8<---------------cut here---------------end--------------->8---