Support multiple ranges

This commit is contained in:
contrapunctus 2022-02-13 13:44:12 +05:30
parent 6553346be1
commit d6cbeeba9e
2 changed files with 26 additions and 18 deletions

View File

@ -38,13 +38,15 @@
;; [[file:chronometrist-third.org::*working-hours][working-hours:1]]
(defcustom chronometrist-third-working-hours nil
"User's working hours for today.
This can be nil, a pair of ISO-8601 timestamps, or a function
which takes no arguments and returns a pair of ISO-8601
timestamps.
This can be nil, a list of one or more ISO-8601 timestamp pairs,
or a function which takes no arguments and returns such a list.
Setting this currently has no effect."
Setting this has no effect at the moment."
:type '(choice (const :tag "No defined working hours" nil)
(cons :tag "Time range" string string)
(repeat :tag "Time ranges"
(cons :tag "Range"
(string :tag "Start")
(string :tag "Stop")))
function)
:group 'chronometrist-third)
;; working-hours:1 ends here
@ -54,10 +56,12 @@ Setting this currently has no effect."
"Return the user's working hours based on DEFAULT-HOURS.
For the possible values of DEFAULT-HOURS, see the variable
`chronometrist-third-working-hours' ."
(cl-typecase default-hours
(cons default-hours)
(function (funcall default-hours))
(nil nil)))
(cond ((and (proper-list-p default-hours)
(seq-every-p #'consp default-hours))
default-hours)
((functionp default-hours)
(chronometrist-third-working-hours (funcall default-hours)))
(t nil)))
;; working-hours:1 ends here
;; [[file:chronometrist-third.org::*divisor][divisor:1]]

View File

@ -51,13 +51,15 @@
#+BEGIN_SRC emacs-lisp
(defcustom chronometrist-third-working-hours nil
"User's working hours for today.
This can be nil, a pair of ISO-8601 timestamps, or a function
which takes no arguments and returns a pair of ISO-8601
timestamps.
This can be nil, a list of one or more ISO-8601 timestamp pairs,
or a function which takes no arguments and returns such a list.
Setting this currently has no effect."
Setting this has no effect at the moment."
:type '(choice (const :tag "No defined working hours" nil)
(cons :tag "Time range" string string)
(repeat :tag "Time ranges"
(cons :tag "Range"
(string :tag "Start")
(string :tag "Stop")))
function)
:group 'chronometrist-third)
#+END_SRC
@ -68,10 +70,12 @@ Setting this currently has no effect."
"Return the user's working hours based on DEFAULT-HOURS.
For the possible values of DEFAULT-HOURS, see the variable
`chronometrist-third-working-hours' ."
(cl-typecase default-hours
(cons default-hours)
(function (funcall default-hours))
(nil nil)))
(cond ((and (proper-list-p default-hours)
(seq-every-p #'consp default-hours))
default-hours)
((functionp default-hours)
(chronometrist-third-working-hours (funcall default-hours)))
(t nil)))
#+END_SRC
** divisor :custom:variable: