now you can schedule dom.

This commit is contained in:
Bryce Covert
2020-09-24 13:02:37 -07:00
parent 99e09b1181
commit 1b56bc9324
4 changed files with 85 additions and 38 deletions

View File

@@ -0,0 +1,15 @@
(ns auto-ap.time-utils
(:require #?(:clj [clj-time.core :as time]
:cljs [cljs-time.core :as time])))
(defn next-dom [date dom]
(when date
(let [candidate (time/date-time (time/year date) (time/month date)
#?(:clj (Math/min (int dom)
(time/day (time/last-day-of-the-month (time/year date) (time/month date))))
:cljs (Math/min dom
(time/day (time/last-day-of-the-month (time/year date) (time/month date))))))]
(if (time/before? candidate date)
(time/plus candidate (time/months 1))
candidate))))