Fork me on GitHub

If I have a time, and an interval, is there an existing function to determine if that time resides within (is contained by) the interval? Are tick interval bounds inclusive, or exclusive, or some mixture? For example org.threeten.extra.Interval

An interval represents the time on the time-line between two Instants. 
The class stores the start and end instants, with the start inclusive and the end exclusive. 
The end instant is always greater than or equal to the start instant.


@dcj maybe coincident? works for your use-case too?


WRT "Are tick interval bounds inclusive or exclusive?" According to the docs:

(= (t.i/new-interval (t/date-time "2000-01-01T00:00")
                   (t/date-time "2001-01-01T00:00"))
   (t.i/bounds (t/year 2000))
   {:tick/beginning (t/date-time "2000-01-01T00:00")
    :tick/end (t/date-time "2001-01-01T00:00")})
(t/in (t/bounds (t/today)) "US/Pacific")
       #time/zoned-date-time "2021-09-17T00:00-07:00[US/Pacific]",
       #time/zoned-date-time "2021-09-18T00:00-07:00[US/Pacific]"}
This leads me to conclude that the :tick/beginning bound is inclusive, and :tick/end is exclusive, anyone disagree???


WRT "how to determine if a time resides within (is contained by) an interval", seems like this would work:

(defn contained-by-interval?
  [t {:keys [tick/beginning tick/end] :as i}]
  (and (t/<= beginning t) (t/< t end)))


The tick docs have been temporarily taken down as they are out of date and the place they were being hosted has some issues. You can access up to date ones here for now (or of course see the repo)

👍 2