emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jan Seeger <jan.seeger@thenybble.de>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] European date format
Date: Fri, 04 Mar 2011 18:56:36 +0100	[thread overview]
Message-ID: <87mxlawyzv.wl%jan.seeger@thenybble.de> (raw)

[-- 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.

             reply	other threads:[~2011-03-04 17:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-04 17:56 Jan Seeger [this message]
2011-03-04 19:04 ` [PATCH] European date format 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

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=87mxlawyzv.wl%jan.seeger@thenybble.de \
    --to=jan.seeger@thenybble.de \
    --cc=emacs-orgmode@gnu.org \
    /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).