Robert Nikander <robert.nikan...@icloud.com> writes:

> The manual here: https://orgmode.org/manual/The-date_002ftime-prompt.html
>
> says that you can use syntax like `+2h` when entering timestamps. It doesn’t 
> seem to work, but `+2d` does. Is the manual simply out of sync with the
> implementation?

I can confirm that +2h syntax is not supported.

The attached patch makes hours work in the time prompt.

Best,
Ihor

>From 21e0680c1443bc3dc3b025f5782276edcf3a7ada Mon Sep 17 00:00:00 2001
Message-Id: <21e0680c1443bc3dc3b025f5782276edcf3a7ada.1639820517.git.yanta...@gmail.com>
From: Ihor Radchenko <yanta...@gmail.com>
Date: Sat, 18 Dec 2021 16:33:57 +0800
Subject: [PATCH] Date/time prompt: Allow input of relative time in hours (e.g.
 +1h)

* lisp/org.el (org-read-date-analyze): Match relative hour specifier.

Fixes https://orgmode.org/list/c9a76efa-1d76-4c5d-941d-afa288a64...@icloud.com
---
 lisp/org.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ce4e08eab..393f45f26 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14536,10 +14536,14 @@ (defun org-read-date-analyze (ans def defdecode)
       (unless deltadef
 	(let ((now (decode-time)))
 	  (setq day (nth 3 now) month (nth 4 now) year (nth 5 now))))
-      (cond ((member deltaw '("d" "")) (setq day (+ day deltan)))
-	    ((equal deltaw "w") (setq day (+ day (* 7 deltan))))
-	    ((equal deltaw "m") (setq month (+ month deltan)))
-	    ((equal deltaw "y") (setq year (+ year deltan)))))
+      (cond ((member deltaw '("h" ""))
+             (when (boundp 'org-time-was-given)
+               (setq org-time-was-given t))
+             (setq hour (+ hour deltan)))
+            ((member deltaw '("d" "")) (setq day (+ day deltan)))
+            ((equal deltaw "w") (setq day (+ day (* 7 deltan))))
+            ((equal deltaw "m") (setq month (+ month deltan)))
+            ((equal deltaw "y") (setq year (+ year deltan)))))
      ((and wday (not (nth 3 tl)))
       ;; Weekday was given, but no day, so pick that day in the week
       ;; on or after the derived date.
-- 
2.32.0

Reply via email to