The current behavior of `org-add-planning-info' does not include the time of day when it is passed the TIME argument. This is because `org-time-was-given' is initially let-bound to nil
during the scope of the function.

The attached patch removes that binding and allows the caller to pass the time of day in the above case.

An example use case I use with org-capture templates:

(defun +org-schedule-relative-to-deadline ()
 "Prompt for optional deadline, then an optional schedule time.
The scheduled default time is the deadline."
 (interactive)
 (condition-case nil
     (org-deadline nil)
   (quit nil))
(let ((org-overriding-default-time (or (org-get-deadline-time (point))
                                        org-overriding-default-time)))
;; works with patch, but without it the time of day is not included in timestamp. (org-schedule nil (org-read-date 'with-time 'to-time nil "SCHEDULE: " org-overriding-default-time))))

>From 2b0840a3963a16b4b92bfdad794a1327aa6f8bd4 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholel...@gmail.com>
Date: Tue, 18 Aug 2020 17:09:50 -0400
Subject: [PATCH] org: (org-add-planning-info): Respect caller's
 `org-time-was-given' value

* lisp/org.el (org-add-planning-info): Respect caller's `org-time-was-given' value

Allows programmatically passing a time of day to `org-schedule'.

e.g. if one wanted to schedule a task relative to its DEADLINE time of day:

(org-schedule nil (org-read-date t t nil "SCHEDULE: "
                                 (org-get-deadline-time (point))))
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index fb95590fc..aabdaebb9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10605,7 +10605,7 @@ among `closed', `deadline', `scheduled' and nil.  TIME indicates
 the time to use.  If none is given, the user is prompted for
 a date.  REMOVE indicates what kind of entries to remove.  An old
 WHAT entry will also be removed."
-  (let (org-time-was-given org-end-time-was-given default-time default-input)
+  (let (org-end-time-was-given default-time default-input)
     (when (and (memq what '(scheduled deadline))
 	       (or (not time)
 		   (and (stringp time)
-- 
2.28.0

Reply via email to