From: Nick Dokos <nicholas.dokos@hp.com>
To: Jan Seeger <jan.seeger@thenybble.de>
Cc: nicholas.dokos@hp.com, emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] European date format
Date: Fri, 04 Mar 2011 14:04:42 -0500 [thread overview]
Message-ID: <3695.1299265482@alphaville.usa.hp.com> (raw)
In-Reply-To: Message from Jan Seeger <jan.seeger@thenybble.de> of "Fri, 04 Mar 2011 18:56:36 +0100." <87mxlawyzv.wl%jan.seeger@thenybble.de>
Jan Seeger <jan.seeger@thenybble.de> 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---
next prev parent reply other threads:[~2011-03-04 19:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-04 17:56 [PATCH] European date format Jan Seeger
2011-03-04 19:04 ` Nick Dokos [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3695.1299265482@alphaville.usa.hp.com \
--to=nicholas.dokos@hp.com \
--cc=emacs-orgmode@gnu.org \
--cc=jan.seeger@thenybble.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).