From fd376c7cf1c6c2ead491316504a8829a7f3ee82b Mon Sep 17 00:00:00 2001 From: contrapunctus Date: Tue, 9 Feb 2021 01:38:17 +0530 Subject: [PATCH] iso-date->ts - use pattern matching --- elisp/chronometrist.el | 9 +++------ elisp/chronometrist.org | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/elisp/chronometrist.el b/elisp/chronometrist.el index 622aa1a..07e34ee 100644 --- a/elisp/chronometrist.el +++ b/elisp/chronometrist.el @@ -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)))) diff --git a/elisp/chronometrist.org b/elisp/chronometrist.org index 56445f8..c8013fd 100644 --- a/elisp/chronometrist.org +++ b/elisp/chronometrist.org @@ -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))))