unexpected results for before? after? on interval
thumbnail opened this issue · 3 comments
thumbnail commented
According to the threethen javadoc an interval is start inclusive and the end exclusive..
The javadoc of the isBefore and isAfter reflect this:
Since intervals do not include their end points, this will return true if the instant equals the end of the interval.
Using java-time however, this is not the case:
i
=> #object[org.threeten.extra.Interval 0x17e871bf "2018-01-01T00:00:00Z/2019-01-01T00:00:00Z"]
i2
=> #object[org.threeten.extra.Interval 0x51897443 "2019-01-01T00:00:00Z/2020-01-01T00:00:00Z"]
(.isBefore i i2)
=> true
(java-time/before? i i2)
=> falseThe issue is a custom impl for single-before? and single-after?:
clojure.java-time/src/java_time/interval.clj
Lines 112 to 118 in 494e181
and can be mitigated by evalling
(extend-type Interval
jt.c/Ordered
(single-before? [i o] (.isBefore i o))
(single-after? [i o] (.isAfter i o)))dm3 commented
This is a problem. I'm not sure why I did the single-before?/after? on the Interval this way. Seems like delegating to the .isBefore/After should be the right choice. Will look into it.