Move date conversion into a function

This commit is contained in:
Tom Willemse 2021-06-24 21:09:22 -07:00
parent 80ab0599af
commit 0aee0a3631

View file

@ -39,26 +39,24 @@
;;; Code: ;;; Code:
(defun tekuti--format-date (date)
"Format DATE into a date that tekuti understands."
(format-time-string "%a, %d %b %Y %H:%M:%S %Z"
(org-timestamp-to-time
(org-timestamp-from-string date))
t))
(defun tekuti-build-data-from-org () (defun tekuti-build-data-from-org ()
(append (append
(mapcar (mapcar
(lambda (pair) (lambda (pair)
(pcase pair (pcase pair
(`("DATE" ,date) (`("DATE" ,date)
(list "DATE" (list "DATE" (tekuti--format-date date)))
(format-time-string
"%a, %d %b %Y %H:%M:%S %Z"
(org-timestamp-to-time
(org-timestamp-from-string date))
t)))
(`("COMMENTS_DATE" ,date) (`("COMMENTS_DATE" ,date)
(list "COMMENTS-CLOSED-DATE" (list "COMMENTS-CLOSED-DATE"
(and (not (string-empty-p date)) (and (not (string-empty-p date))
(format-time-string (tekuti--format-date date))))
"%a, %d %b %Y %H:%M:%S %Z"
(org-timestamp-to-time
(org-timestamp-from-string date))
t))))
(_ pair))) (_ pair)))
(org-collect-keywords '("TITLE" "TAGS" "STATUS" "COMMENTS" "DATE" "COMMENTS_DATE"))) (org-collect-keywords '("TITLE" "TAGS" "STATUS" "COMMENTS" "DATE" "COMMENTS_DATE")))
(list (list