From e9e249ea49054a46153a633ecf47d08a2d588c8e Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 28 Dec 2011 17:12:25 +0100 Subject: [PATCH] New option `org-export-date-timestamp-format'. * org-exp.el (org-export-date-timestamp-format): New option to define the way a timestamp in #+DATE will be exported. (org-infile-export-plist): Use the new option. Thanks to Torsten Wagner for this idea. --- doc/org.texi | 7 ++++--- lisp/org-exp.el | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 6b189bd6d..1d0790f1a 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -9634,10 +9634,11 @@ Insert template with export options, see example below. @vindex user-full-name @vindex user-mail-address @vindex org-export-default-language +@vindex org-export-date-timestamp-format @example #+TITLE: the title to be shown (default is the buffer name) #+AUTHOR: the author (default taken from @code{user-full-name}) -#+DATE: a date, fixed, or a format string for @code{format-time-string} +#+DATE: a date, an Org timestamp@footnote{@code{org-export-date-timestamp-format} defines how this timestamp will be exported.}, or a format string for @code{format-time-string} #+EMAIL: his/her email address (default from @code{user-mail-address}) #+DESCRIPTION: the page description, e.g.@: for the XHTML meta tag #+KEYWORDS: the page keywords, e.g.@: for the XHTML meta tag @@ -9656,8 +9657,8 @@ Insert template with export options, see example below. @end example @noindent -The OPTIONS line is a compact@footnote{If you want to configure many options -this way, you can use several OPTIONS lines.} form to specify export +The @code{#+OPTIONS} line is a compact@footnote{If you want to configure many options +this way, you can use several @code{#+OPTIONS} lines.} form to specify export settings. Here you can: @cindex headline levels @cindex section-numbers diff --git a/lisp/org-exp.el b/lisp/org-exp.el index eae5be7e9..31c41f94c 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -217,6 +217,11 @@ and in `org-clock-clocktable-language-setup'." :group 'org-export-general :type 'string) +(defcustom org-export-date-timestamp-format "%Y-%m-%d" + "Time string format for Org timestamps in the #+DATE option." + :group 'org-export-general + :type 'string) + (defvar org-export-page-description "" "The page description, for the XHTML meta tag. This is best set with the #+DESCRIPTION line in a file, it does not make @@ -726,6 +731,7 @@ must accept the property list as an argument, and must return the (possibly modified) list.") ;; FIXME: should we fold case here? + (defun org-infile-export-plist () "Return the property list with file-local settings for export." (save-excursion @@ -759,7 +765,15 @@ modified) list.") ((string-equal key "TITLE") (setq p (plist-put p :title val))) ((string-equal key "AUTHOR")(setq p (plist-put p :author val))) ((string-equal key "EMAIL") (setq p (plist-put p :email val))) - ((string-equal key "DATE") (setq p (plist-put p :date val))) + ((string-equal key "DATE") + ;; If date is an Org timestamp, convert it to a time + ;; string using `org-export-date-timestamp-format' + (when (string-match org-ts-regexp3 val) + (setq val (format-time-string + org-export-date-timestamp-format + (apply 'encode-time (org-parse-time-string + (match-string 0 val)))))) + (setq p (plist-put p :date val))) ((string-equal key "KEYWORDS") (setq p (plist-put p :keywords val))) ((string-equal key "DESCRIPTION") (setq p (plist-put p :description val))) -- 2.11.4.GIT