iso-date->ts - use pattern matching

This commit is contained in:
contrapunctus 2021-02-09 01:38:17 +05:30
parent aab2590e98
commit fd376c7cf1
2 changed files with 6 additions and 12 deletions

View File

@ -712,12 +712,9 @@ TS must be a ts struct (see `ts.el')."
(defun chronometrist-iso-date->ts (date)
"Return a ts struct (see `ts.el') representing DATE.
DATE should be an ISO-8601 date string (\"YYYY-MM-DD\")."
(let* ((date-list (mapcar #'string-to-number
(split-string date "-")))
(day (caddr date-list))
(month (cadr date-list))
(year (car date-list)))
DATE should be an ISO-8601 date string (\"YYYY-MM-DD\")."
(-let [(year month day) (mapcar #'string-to-number
(split-string date "-"))]
(ts-update
(make-ts :hour 0 :minute 0 :second 0
:day day :month month :year year))))

View File

@ -855,12 +855,9 @@ TS must be a ts struct (see `ts.el')."
#+BEGIN_SRC emacs-lisp
(defun chronometrist-iso-date->ts (date)
"Return a ts struct (see `ts.el') representing DATE.
DATE should be an ISO-8601 date string (\"YYYY-MM-DD\")."
(let* ((date-list (mapcar #'string-to-number
(split-string date "-")))
(day (caddr date-list))
(month (cadr date-list))
(year (car date-list)))
DATE should be an ISO-8601 date string (\"YYYY-MM-DD\")."
(-let [(year month day) (mapcar #'string-to-number
(split-string date "-"))]
(ts-update
(make-ts :hour 0 :minute 0 :second 0
:day day :month month :year year))))