You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
821 B
34 lines
821 B
4 years ago
|
(ns working-hours.period
|
||
|
(:require [working-hours.hours :as hours])
|
||
|
)
|
||
|
|
||
|
(def working-hours-per-day (hours/new "08:48"))
|
||
|
|
||
|
(defn worked-so-far [start lunch-break lunch-return now]
|
||
|
"Return the hours worked so far."
|
||
|
(if (hours/preceeds? now lunch-return)
|
||
|
(hours/sub start now)
|
||
|
(hours/add (hours/sub start lunch-break)
|
||
|
(hours/sub lunch-return now))
|
||
|
)
|
||
|
)
|
||
|
|
||
|
(defn extra? [worked]
|
||
|
"Checks if the worked time is now on extra time."
|
||
|
(> worked working-hours-per-day)
|
||
|
)
|
||
|
|
||
|
(defn extra-work [worked]
|
||
|
"Return the hours of extra work done."
|
||
|
(if (extra? worked)
|
||
|
(hours/sub working-hours-per-day worked)
|
||
|
nil)
|
||
|
)
|
||
|
|
||
|
(defn work-remaining [worked]
|
||
|
"Return the hours remaing to complete the working day hours."
|
||
|
(if (extra? worked)
|
||
|
nil
|
||
|
(hours/sub worked working-hours-per-day))
|
||
|
)
|