From: Jambunathan K <kjambunathan@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-odt: Emit OD compatible date string in the default case
Date: Wed, 27 Jul 2011 11:29:50 +0530 [thread overview]
Message-ID: <81pqkwfell.fsf@gmail.com> (raw)
[-- Attachment #1: 0002-org-odt-Emit-OD-compatible-date-string-in-the-defaul.patch --]
[-- Type: text/plain, Size: 2227 bytes --]
From 263ede1b312bb9330281e179b6d767c07cfbf12f Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Wed, 27 Jul 2011 11:27:23 +0530
Subject: [PATCH 2/2] org-odt: Emit OD compatible date string in the default case
* contrib/lisp/org-odt.el (org-odt-format-date): New
(org-odt-update-meta-file): Use the above routine
Knocks off an error reported by
http://tools.services.openoffice.org/odfvalidator/
---
contrib/lisp/org-odt.el | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el
index bab7590..fbbf638 100644
--- a/contrib/lisp/org-odt.el
+++ b/contrib/lisp/org-odt.el
@@ -1351,10 +1351,36 @@ MAY-INLINE-P allows inlining it as an image."
(message "Created %s" target)
(set-buffer (find-file-noselect target t)))
+(defun org-odt-format-date (date)
+ (let ((warning-msg
+ "OpenDocument files require that dates be in ISO-8601 format. Please review your DATE options for compatibility."))
+ ;; If the user is not careful with the date specification, an
+ ;; invalid meta.xml will be emitted.
+
+ ;; For now honor user's diktat and let him off with a warning
+ ;; message. This is OK as LibreOffice (and possibly other
+ ;; apps) doesn't deem this deviation as critical and continue
+ ;; to load the file.
+
+ ;; FIXME: Surely there a better way to handle this. Revisit this
+ ;; later.
+ (cond
+ ((and date (string-match "%" date))
+ ;; Honor user's diktat. See comments above
+ (org-lparse-warn warning-msg)
+ (format-time-string date))
+ (date
+ ;; Honor user's diktat. See comments above
+ (org-lparse-warn warning-msg)
+ date)
+ (t
+ ;; ISO 8601 format
+ (format-time-string "%Y-%m-%dT%T%:z")))))
+
(defun org-odt-update-meta-file (opt-plist)
(with-current-buffer
(find-file-noselect (expand-file-name "meta.xml") t)
- (let ((date (or (plist-get opt-plist :effective-date) ""))
+ (let ((date (org-odt-format-date (plist-get opt-plist :date)))
(author (or (plist-get opt-plist :author) ""))
(email (plist-get opt-plist :email))
(keywords (plist-get opt-plist :keywords))
--
1.7.2.3
[-- Attachment #2: Type: text/plain, Size: 5 bytes --]
--
next reply other threads:[~2011-07-27 6:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-27 5:59 Jambunathan K [this message]
2011-07-27 12:43 ` [PATCH] org-odt: Emit OD compatible date string in the default case Bastien
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=81pqkwfell.fsf@gmail.com \
--to=kjambunathan@gmail.com \
--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 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.