From 6485cccc7213f526dcd2ee0be2eef3925273f966 Mon Sep 17 00:00:00 2001 From: Jim Berlage Date: Tue, 18 Jun 2019 08:13:33 -0500 Subject: [PATCH] Port cljs-time.core/min-date and cljs-time.core/max-date from the clj-time API --- .gitignore | 1 + src/cljs_time/core.cljs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index 620b85a..c937688 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ out/ clojurescript/ doc/ bin/ +.idea/ diff --git a/src/cljs_time/core.cljs b/src/cljs_time/core.cljs index e77873f..fd35056 100644 --- a/src/cljs_time/core.cljs +++ b/src/cljs_time/core.cljs @@ -312,6 +312,16 @@ expected."} [] (doto (goog.date.UtcDateTime.) (.setTime 0))) +(defn min-date + "Minimum of the provided DateTimes." + [dt & dts] + (reduce #(if (before? %1 %2) %1 %2) dt dts)) + +(defn max-date + "Maximum of the provided DateTimes." + [dt & dts] + (reduce #(if (after? %1 %2) %1 %2) dt dts)) + (defn date-midnight "Constructs and returns a new DateTime at midnight in UTC.