Function: denote-date-prompt

denote-date-prompt is a byte-compiled function defined in denote.el.

Signature

(denote-date-prompt &optional INITIAL-DATE PROMPT-TEXT)

Documentation

Prompt for date, expecting YYYY-MM-DD or that plus HH:MM.

Use Org's more advanced date selection utility if the user option denote-date-prompt-use-org-read-date is non-nil.

With optional INITIAL-DATE use it as the initial minibuffer text. With optional PROMPT-TEXT use it in the minibuffer instead of the default prompt.

INITIAL-DATE is a string that can be processed by denote-valid-date-p, a value that can be parsed by decode-time or nil.

Source Code

;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defun denote-date-prompt (&optional initial-date prompt-text)
  "Prompt for date, expecting YYYY-MM-DD or that plus HH:MM.
Use Org's more advanced date selection utility if the user option
`denote-date-prompt-use-org-read-date' is non-nil.

With optional INITIAL-DATE use it as the initial minibuffer
text.  With optional PROMPT-TEXT use it in the minibuffer instead
of the default prompt.

INITIAL-DATE is a string that can be processed by `denote-valid-date-p',
a value that can be parsed by `decode-time' or nil."
  (let ((initial-date (denote-valid-date-p initial-date)))
    (if (and denote-date-prompt-use-org-read-date
             (require 'org nil :no-error))
        (let* ((time (org-read-date nil t nil prompt-text (denote--date-convert initial-date :list)))
               (org-time-seconds (format-time-string "%S" time))
               (cur-time-seconds (format-time-string "%S" (current-time))))
          ;; When the user does not input a time, org-read-date defaults to 00 for seconds.
          ;; When the seconds are 00, we add the current seconds to avoid identifier collisions.
          (when (string-equal "00" org-time-seconds)
            (setq time (time-add time (string-to-number cur-time-seconds))))
          (format-time-string "%Y-%m-%d %H:%M:%S" time))
      (read-string
       (or prompt-text "DATE and TIME for note (e.g. 2022-06-16 14:30): ")
       (denote--date-convert initial-date :string)
       'denote-date-history))))