dm3/clojure.java-time

Support org.threeten.extra LocalDateRange?

jdf-id-au opened this issue · 1 comments

Thanks for an elegant wrapper.

I currently have to drop into interop to make a LocalDateRange from org.threeten.extra. Do you have any plans to bring it in? I note you already support Interval from that library.

Can I help? I might need you to point me in the right direction to get started.

dm3 commented

Sure, you can look in the src/java_time/interval.clj to see how the Interval is integrated. A range is different from interval as it doesn't capture a continuous stretch of time. I don't think there's an entity like that currently implemented in this library.

Do you need the LocalDateRange for the sake of Java interop or do you want to express a domain concern in Clojure? The reason I'm asking is that I usually use a Clojure sequence to get a range of dates like so:

user=> (take 3 (j/iterate j/plus (j/local-date) (j/days 1)))
(#object[java.time.LocalDate 0x1dc677bd "2018-09-30"]
 #object[java.time.LocalDate 0x367215e9 "2018-10-01"]
 #object[java.time.LocalDate 0x31e9a042 "2018-10-02"])

then you have your normal sequence transformations to get whichever info is needed. I guess it would still be useful to have some higher level range-specific operations implemented, like intersection, comparison, etc. as well as maintaining the Seq interface to allow direct iteration. Also, having a generic interface suitable for minutes/hours/local dates/etc. would probably make sense - what do you think?