branch: externals/denote
commit f6a1276b4c658c29f2870270c7a09c669ec756f1
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Fix error of date parsing in Emacs 28
    
    The idea is to turn 2020-01-15 into 2020-01-15 16:19 so that the hour
    and minute component is not left to 00:00.
    
    This reduces the burden on the user who would otherwise need to input
    that value in order to avoid the error of duplicate identifiers.
    
    It also addresses a difference between Emacs 28 and Emacs 29 where the
    former does not read dates without a time component.
    
    Thanks to Peter Prevos for the feedback in issue 58 over at the GitHub
    mirror: <https://github.com/protesilaos/denote/issues/58>.
---
 denote.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/denote.el b/denote.el
index 8a17fbe8a7..3752581567 100644
--- a/denote.el
+++ b/denote.el
@@ -827,9 +827,25 @@ is set to \\'(file-type title keywords)."
    "DATE and TIME for note (e.g. 2022-06-16 14:30): "
    nil 'denote--date-history))
 
+(defun denote--date-add-current-time (date)
+  "Add current time to date, if necessary.
+The idea is to turn 2020-01-15 into 2020-01-15 16:19 so that the
+hour and minute component is not left to 00:00.
+
+This reduces the burden on the user who would otherwise need to
+input that value in order to avoid the error of duplicate
+identifiers.
+
+It also addresses a difference between Emacs 28 and Emacs 29
+where the former does not read dates without a time component."
+  (if (<= (length date) 10)
+      (format "%s %s" date (format-time-string "%H:%M:%S" (current-time)))
+    date))
+
 (defun denote--valid-date (date)
   "Return DATE if parsed by `date-to-time', else signal error."
-  (date-to-time date))
+  (let ((datetime (denote--date-add-current-time date)))
+    (date-to-time datetime)))
 
 (defun denote--buffer-file-names ()
   "Return file names of active buffers."

Reply via email to