Why Not a Function #26: months-to

(require '[cljs-time.core :as t])

(defn months-to
     (t/first-day-of-the-month (t/today))
     (t/first-day-of-the-month date)

months-to builds on top of interval-in to provide the number of months that are between today and a date specified. It ignores the day of the month. Can be used in pair with add-months.

(months-to (t/today))
=> 0

(months-to (t/local-date 2020 05 01))
=> 1
Written on April 17, 2020