-
-
Save sritchie/542ce3e9533201c3b457 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
(defn delta-periods | |
[start end unit span] | |
(let [[years units] (map #(delta % start end) [year unit]) | |
top (per-year unit span)] | |
(+ (* top years) | |
(int (/ units span))))) | |
(defn sixteens | |
[start end] | |
(delta-periods start end day 16)) | |
(defn eights | |
[start end] | |
(delta-periods start end day 8)) | |
(defn months | |
[start end] | |
(delta-periods start end month 1)) | |
;; or this: | |
(defn delta-periods | |
[unit span] | |
(fn [start end] | |
(let [[years units] (map #(delta % start end) [year unit]) | |
top (per-year unit span)] | |
(+ (* top years) | |
(int (/ units span)))))) | |
(def sixteens (delta-periods day 16)) | |
(def eights (delta-periods day 8)) | |
(def months (delta-periods month 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment