Make stylistic change to denote--date-parse-string

The original was contributed by Jeff Valk in commit 9083ad7, pull
request 722: <https://github.com/protesilaos/denote/pull/722>.
This commit is contained in:
Protesilaos 2026-08-10 11:38:16 +03:00
parent 8f7e988a67
commit 9ae9d0e1ea
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA

View file

@ -3675,12 +3675,14 @@ here for clarity."
(if date (format-time-string "%F %T" date) "")))) (if date (format-time-string "%F %T" date) ""))))
(defun denote--date-parse-string (date) (defun denote--date-parse-string (date)
"Convert DATE to Denote's preferred string format if a recognized pattern. "Convert DATE to Denote's preferred string format.
Otherwise, return DATE unchanged. Currently supports Unix timestamps." If DATE is a Unix timestamp, convert it accordingly."
(cond ((string-match "[0-9]\\{10\\}" date) ; seconds since epoch (if-let* ((_ (string-match "[0-9]\\{10\\}" date)) ; seconds since epoch
(let ((secs (string-to-number (match-string 0 date)))) (match (match-string 0 date))
(format-time-string "%Y-%m-%d %H:%M:%S" (seconds-to-time secs)))) (seconds (string-to-number match))
(t date))) (time (seconds-to-time seconds)))
(format-time-string "%Y-%m-%d %H:%M:%S" time)
date))
(defun denote-date-prompt (&optional initial-date prompt-text) (defun denote-date-prompt (&optional initial-date prompt-text)
"Prompt for date, expecting YYYY-MM-DD or that plus HH:MM. "Prompt for date, expecting YYYY-MM-DD or that plus HH:MM.