diff options
author | Bastien Guerry <bzg@altern.org> | 2012-09-24 08:28:45 +0200 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2012-09-24 08:28:45 +0200 |
commit | b61ff117bc129e5843c7f38592385c07dba04bf5 (patch) | |
tree | 9b900cc1e70dd4628ce7ae1d91c0275be0a7ca85 | |
parent | ec9f52d185753a943a1a56e6c5155571fce9307a (diff) | |
download | org-mode-b61ff117bc129e5843c7f38592385c07dba04bf5.tar.gz |
org-capture.el: Set a correct time value with file+datetree+prompt
* org-capture.el (org-capture-set-target-location): Set a
correct time value when storing a note in a datetree and
prompting the user for a date.
Thanks to Gregor Zattler for reporting this.
-rw-r--r-- | lisp/org-capture.el | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el index e635a42..188c79e 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -880,11 +880,22 @@ already gone. Any prefix argument will be passed to the refile command." (let ((prompt-time (org-read-date nil t nil "Date for tree entry:" (current-time)))) - (org-capture-put :prompt-time prompt-time - :default-time prompt-time) + (org-capture-put + :default-time + (cond ((and (not org-time-was-given) + (not (= (time-to-days prompt-time) (org-today)))) + ;; Use 00:00 when no time is given for another date than today? + (apply 'encode-time (append '(0 0 0) (cdddr (decode-time prompt-time))))) + ((string-match "\\([^ ]+\\)--?[^ ]+[ ]+\\(.*\\)" org-read-date-final-answer) + ;; Replace any time range by its start + (apply 'encode-time + (org-read-date-analyze + (replace-match "\\1 \\2" nil nil org-read-date-final-answer) + prompt-time (decode-time prompt-time)))) + (t prompt-time))) (time-to-days prompt-time))) (t - ;; current date, possible corrected for late night workers + ;; current date, possibly corrected for late night workers (org-today)))))) ((eq (car target) 'file+function) |