From e01daa00becbbe2bde49ec7ab013fd1510a9bbb6 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 6 Apr 2013 14:10:59 +0200 Subject: [PATCH] ox-publish: Fix "bad timestamp" error with some DATE values * lisp/ox-publish.el (org-publish-find-date): Fix "bad timestamp" error with some DATE values: :date property in communication channel is no longer a string. --- lisp/ox-publish.el | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 0c220143b..213c76747 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -810,22 +810,27 @@ Default for SITEMAP-FILENAME is 'sitemap.org'." (defun org-publish-find-date (file) "Find the date of FILE in project. -If FILE provides a #+date keyword use it else use the file -system's modification time. - -It returns time in `current-time' format." +If FILE provides a DATE keyword use it else use the file system's +modification time. Return time in `current-time' format." (let* ((org-inhibit-startup t) (visiting (find-buffer-visiting file)) (file-buf (or visiting (find-file-noselect file nil))) (date (plist-get (with-current-buffer file-buf (org-mode) - (org-export--get-inbuffer-options)) + (org-export-get-environment)) :date))) (unless visiting (kill-buffer file-buf)) - (if date (org-time-string-to-time date) - (when (file-exists-p file) - (nth 5 (file-attributes file)))))) + ;; DATE is either a timestamp object or a secondary string. If it + ;; is a timestamp or if the secondary string contains a timestamp, + ;; convert it to internal format. Otherwise, use FILE + ;; modification time. + (cond ((eq (org-element-type date) 'timestamp) + (org-time-string-to-time (org-element-interpret-data date))) + ((let ((ts (and (consp date) (assq 'timestamp date)))) + (and ts (org-string-nw-p (org-element-interpret-data ts))))) + ((file-exists-p file) (nth 5 (file-attributes file))) + (t (error "No such file: \"%s\"" file)))))