Last active
May 15, 2020 08:00
-
-
Save Heliosmaster/844f5fdd0a114c3ec90b4cff5c15ef59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[java-time :as t]) | |
(defn at [t {:keys [hours minutes seconds]}] | |
(let [m (t/as-map t)] | |
(cond-> t | |
hours (t/plus (t/hours (- hours (:hour-of-day m)))) | |
minutes (t/plus (t/minutes (- minutes (:minute-of-hour m)))) | |
seconds (t/plus (t/seconds (- seconds (:second-of-minute m))))))) | |
(defn next-working-day [t] | |
(let [{:keys [day-of-week]} (t/as-map t) | |
delta-day (if (>= day-of-week 5) | |
(- 8 day-of-week) | |
1)] | |
(-> t | |
(t/plus (t/days delta-day)) | |
(at {:hours 9})))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment