Compare commits

...
This repository has been archived on 2022-05-13. You can view files and clone it, but cannot push or open issues or pull requests.

10 Commits

Author SHA1 Message Date
contrapunctus 2cca269d33 Merge branch 'dev' into third-time 2022-02-25 15:28:12 +05:30
contrapunctus 855b802612 Merge branch 'doc' into third-time 2022-02-14 09:03:24 +05:30
contrapunctus 8b4cd461d8 Merge branch 'dev' into third-time 2022-02-14 08:07:22 +05:30
contrapunctus 8fc0e5718e Merge branch 'doc' into third-time 2022-02-14 08:07:14 +05:30
contrapunctus 16061d0f85 Add Third Time notes 2022-02-13 16:03:02 +05:30
contrapunctus d6cbeeba9e Support multiple ranges 2022-02-13 13:44:12 +05:30
contrapunctus 6553346be1 Use newlines in alerts 2022-02-13 13:24:00 +05:30
contrapunctus 267f17e57d Allow function as value for break time variable 2022-02-13 11:03:41 +05:30
contrapunctus a8f213bbd2 Merge branch 'doc' into third-time 2022-02-13 02:54:26 +05:30
contrapunctus 65d6f8ddd6 Add working hours custom variable 2022-02-13 02:54:18 +05:30
2 changed files with 68 additions and 6 deletions

View File

@ -35,6 +35,35 @@
:group 'chronometrist)
;; group:1 ends here
;; [[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 list of one or more ISO-8601 timestamp pairs,
or a function which takes no arguments and returns such a list.
Setting this has no effect at the moment."
:type '(choice (const :tag "No defined working hours" nil)
(repeat :tag "Time ranges"
(cons :tag "Range"
(string :tag "Start")
(string :tag "Stop")))
function)
:group 'chronometrist-third)
;; working-hours:1 ends here
;; [[file:chronometrist-third.org::*working-hours][working-hours:1]]
(defun chronometrist-third-working-hours (default-hours)
"Return the user's working hours based on DEFAULT-HOURS.
For the possible values of DEFAULT-HOURS, see the variable
`chronometrist-third-working-hours' ."
(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]]
(defcustom chronometrist-third-divisor 3
"Number to determine accumulation of break time relative to work time."
@ -139,10 +168,10 @@ and stopped when they clock in."
(setq chronometrist-third-break-time (if (> new-break 0) new-break 0))
(alert
(if (zerop chronometrist-third-break-time)
(format "You have used up all %s of your break time (%s break)"
(format "You have used up all %s of your break time\n(%s break)"
(format-seconds chronometrist-third-duration-format old-break)
used-break-string)
(format "You have used %s of your break time (%s left)"
(format "You have used %s of your break time\n(%s left)"
used-break-string
(format-seconds chronometrist-third-duration-format chronometrist-third-break-time)))))))
;; clock-in:1 ends here
@ -155,7 +184,7 @@ break time is up."
(let* ((latest-work-duration (chronometrist-interval (chronometrist-latest-record (chronometrist-active-backend))))
(break-time-increment (/ latest-work-duration chronometrist-third-divisor)))
(cl-incf chronometrist-third-break-time break-time-increment)
(alert (format "You have gained %s of break time (%s total)"
(alert (format "You have gained %s of break time\n(%s total)"
(format-seconds chronometrist-third-duration-format break-time-increment)
(format-seconds chronometrist-third-duration-format chronometrist-third-break-time)))
;; start alert timer(s)

View File

@ -47,6 +47,39 @@
:group 'chronometrist)
#+END_SRC
** TODO working-hours :custom:variable:
Supporting multiple ranges per day may be a little overkill - from my reading of the Third Time post, my understanding is that each day has one large working hours range which includes all breaks. That would mean you really /don't/ want more than one range...
#+BEGIN_SRC emacs-lisp
(defcustom chronometrist-third-working-hours nil
"User's working hours for today.
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 has no effect at the moment."
:type '(choice (const :tag "No defined working hours" nil)
(repeat :tag "Time ranges"
(cons :tag "Range"
(string :tag "Start")
(string :tag "Stop")))
function)
:group 'chronometrist-third)
#+END_SRC
** working-hours :procedure:
#+BEGIN_SRC emacs-lisp
(defun chronometrist-third-working-hours (default-hours)
"Return the user's working hours based on DEFAULT-HOURS.
For the possible values of DEFAULT-HOURS, see the variable
`chronometrist-third-working-hours' ."
(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:
#+BEGIN_SRC emacs-lisp
(defcustom chronometrist-third-divisor 3
@ -163,10 +196,10 @@ and stopped when they clock in."
(setq chronometrist-third-break-time (if (> new-break 0) new-break 0))
(alert
(if (zerop chronometrist-third-break-time)
(format "You have used up all %s of your break time (%s break)"
(format "You have used up all %s of your break time\n(%s break)"
(format-seconds chronometrist-third-duration-format old-break)
used-break-string)
(format "You have used %s of your break time (%s left)"
(format "You have used %s of your break time\n(%s left)"
used-break-string
(format-seconds chronometrist-third-duration-format chronometrist-third-break-time)))))))
#+END_SRC
@ -180,7 +213,7 @@ break time is up."
(let* ((latest-work-duration (chronometrist-interval (chronometrist-latest-record (chronometrist-active-backend))))
(break-time-increment (/ latest-work-duration chronometrist-third-divisor)))
(cl-incf chronometrist-third-break-time break-time-increment)
(alert (format "You have gained %s of break time (%s total)"
(alert (format "You have gained %s of break time\n(%s total)"
(format-seconds chronometrist-third-duration-format break-time-increment)
(format-seconds chronometrist-third-duration-format chronometrist-third-break-time)))
;; start alert timer(s)