andrewmcveigh / cljs-time

A clj-time inspired date library for clojurescript.
342 stars 57 forks source link

Add inclusivity to within? #132

Open foilofbob opened 6 years ago

foilofbob commented 6 years ago

The within? function has the inclusivity on the end date commented out currently, and the comments suggest that it should not be.

(defn within?
  "With 2 arguments: Returns true if the given Interval contains the given
  DateTime. Note that if the DateTime is exactly equal to the
  end of the interval, this function returns false.

  With 3 arguments: Returns true if the start DateTime is
  equal to or before and the end DateTime is equal to or after the test
  DateTime."
  ([{:keys [start end]} date]
   (within? start end date))
  ([start end date]
   (or (= start date)
       ;(= end date)
       (and (before? start date) (after? end date)))))