Skip to content

Instantly share code, notes, and snippets.

@Heliosmaster
Last active May 15, 2020 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Heliosmaster/844f5fdd0a114c3ec90b4cff5c15ef59 to your computer and use it in GitHub Desktop.
Save Heliosmaster/844f5fdd0a114c3ec90b4cff5c15ef59 to your computer and use it in GitHub Desktop.
(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