Implement date-properties
This commit is contained in:
parent
90d3f73cdf
commit
6dc89776b7
|
@ -413,6 +413,21 @@ active backend."
|
|||
:group 'chronometrist)
|
||||
;; task-list:1 ends here
|
||||
|
||||
;; [[file:chronometrist.org::*date-properties][date-properties:1]]
|
||||
(defun chronometrist-date-properties (date-records)
|
||||
"Return properties for DATE-RECORDS, if any.
|
||||
DATE-RECORDS must be a tagged list acceptable as a hash value
|
||||
in a hash table returned by `chronometrist-to-hash-table'."
|
||||
(cl-loop with valuep
|
||||
for elt in date-records
|
||||
when (keywordp elt)
|
||||
collect (progn (setq valuep t) elt) into plist
|
||||
else when valuep
|
||||
collect (progn (setq valuep nil) elt) into plist
|
||||
else when (and (not (keywordp elt)) (not valuep))
|
||||
do (cl-return plist)))
|
||||
;; date-properties:1 ends here
|
||||
|
||||
;; [[file:chronometrist.org::*iso-to-ts][iso-to-ts:1]]
|
||||
(defun chronometrist-iso-to-ts (timestamp)
|
||||
"Convert TIMESTAMP to a TS struct. (see `ts.el')
|
||||
|
|
|
@ -946,6 +946,24 @@ active backend."
|
|||
:group 'chronometrist)
|
||||
#+END_SRC
|
||||
|
||||
*** date-properties :function:
|
||||
[[file:tests/chronometrist-tests.org::#date-properties][tests]]
|
||||
|
||||
#+BEGIN_SRC elisp
|
||||
(defun chronometrist-date-properties (date-records)
|
||||
"Return properties for DATE-RECORDS, if any.
|
||||
DATE-RECORDS must be a tagged list acceptable as a hash value
|
||||
in a hash table returned by `chronometrist-to-hash-table'."
|
||||
(cl-loop with valuep
|
||||
for elt in date-records
|
||||
when (keywordp elt)
|
||||
collect (progn (setq valuep t) elt) into plist
|
||||
else when valuep
|
||||
collect (progn (setq valuep nil) elt) into plist
|
||||
else when (and (not (keywordp elt)) (not valuep))
|
||||
do (cl-return plist)))
|
||||
#+END_SRC
|
||||
|
||||
** Time functions
|
||||
*** iso-to-ts :function:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
|
@ -1349,7 +1367,6 @@ IN-SUBLIST, if non-nil, means point is inside an inner list."
|
|||
:PROPERTIES:
|
||||
:CUSTOM_ID: program-backend
|
||||
:END:
|
||||
|
||||
*** chronometrist-file :custom:variable:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defcustom chronometrist-file
|
||||
|
|
|
@ -233,6 +233,27 @@ BACKEND-VAR is bound to each backend in
|
|||
(should (seq-every-p #'stringp task-list))))
|
||||
#+END_SRC
|
||||
|
||||
*** date-properties
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: date-properties
|
||||
:END:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(ert-deftest chronometrist-date-properties ()
|
||||
(should
|
||||
(not (chronometrist-date-properties
|
||||
'((:name "Programming" :start "2022-02-12T06:54:01+0530" :stop "2022-02-12T07:41:33+0530")
|
||||
(:name "OSM" :start "2022-02-12T21:43:50+0530" :stop "2022-02-12T22:14:38+0530")
|
||||
(:name "Programming" :start "2022-02-12T23:44:37+0530" :stop "2022-02-13T00:00:00+0530")))))
|
||||
(should
|
||||
(equal
|
||||
(chronometrist-date-properties
|
||||
'(:foo 1 :bar "2" :baz (frob)
|
||||
(:name "Programming" :start "2022-02-12T06:54:01+0530" :stop "2022-02-12T07:41:33+0530")
|
||||
(:name "OSM" :start "2022-02-12T21:43:50+0530" :stop "2022-02-12T22:14:38+0530")
|
||||
(:name "Programming" :start "2022-02-12T23:44:37+0530" :stop "2022-02-13T00:00:00+0530")))
|
||||
'(:foo 1 :bar "2" :baz (frob)))))
|
||||
#+END_SRC
|
||||
|
||||
** time functions
|
||||
*** format-duration-long :pure:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
|
|
Reference in New Issue