mirror of
https://github.com/protesilaos/denote.git
synced 2026-09-10 07:16:20 -04:00
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:
parent
8f7e988a67
commit
9ae9d0e1ea
14
denote.el
14
denote.el
|
|
@ -3675,12 +3675,14 @@ here for clarity."
|
|||
(if date (format-time-string "%F %T" date) ""))))
|
||||
|
||||
(defun denote--date-parse-string (date)
|
||||
"Convert DATE to Denote's preferred string format if a recognized pattern.
|
||||
Otherwise, return DATE unchanged. Currently supports Unix timestamps."
|
||||
(cond ((string-match "[0-9]\\{10\\}" date) ; seconds since epoch
|
||||
(let ((secs (string-to-number (match-string 0 date))))
|
||||
(format-time-string "%Y-%m-%d %H:%M:%S" (seconds-to-time secs))))
|
||||
(t date)))
|
||||
"Convert DATE to Denote's preferred string format.
|
||||
If DATE is a Unix timestamp, convert it accordingly."
|
||||
(if-let* ((_ (string-match "[0-9]\\{10\\}" date)) ; seconds since epoch
|
||||
(match (match-string 0 date))
|
||||
(seconds (string-to-number match))
|
||||
(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)
|
||||
"Prompt for date, expecting YYYY-MM-DD or that plus HH:MM.
|
||||
|
|
|
|||
Loading…
Reference in a new issue