From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jambunathan K Subject: [PATCH] org-odt: Emit OD compatible date string in the default case Date: Wed, 27 Jul 2011 11:29:50 +0530 Message-ID: <81pqkwfell.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:36550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlxA8-0004FB-VC for emacs-orgmode@gnu.org; Wed, 27 Jul 2011 02:00:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlxA8-0003j0-1E for emacs-orgmode@gnu.org; Wed, 27 Jul 2011 02:00:08 -0400 Received: from mail-gx0-f169.google.com ([209.85.161.169]:37966) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlxA7-0003ic-QA for emacs-orgmode@gnu.org; Wed, 27 Jul 2011 02:00:07 -0400 Received: by gxk23 with SMTP id 23so962167gxk.0 for ; Tue, 26 Jul 2011 23:00:06 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0002-org-odt-Emit-OD-compatible-date-string-in-the-defaul.patch Content-Description: 0002-org-odt-Emit-OD-compatible-date-string-in-the-defaul.patch >From 263ede1b312bb9330281e179b6d767c07cfbf12f Mon Sep 17 00:00:00 2001 From: Jambunathan K 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 --=-=-= Content-Type: text/plain -- --=-=-=--