Fork me on GitHub
#juxt
<
2023-06-26
>
Marius15:06:55

Hi all! I know that intervals in tick are in alpha and not maintained, but this example should work, right? What am I doing wrong?

(let [a (t.interval/new-interval (t/new-date 2022 02 01) (t/new-date 2022 02 02))
      b (t.interval/new-interval (t/new-date 2022 02 15) (t/new-date 2022 03 03))]
    (t.interval/union a b))
gives me
; Error printing return value (IllegalArgumentException) at clojure.core/-cache-protocol-fn (core_deftype.clj:584).
; No implementation of method: :beginning of protocol: #'tick.protocols/ITimeSpan found for class: clojure.lang.MapEntry

henryw37415:06:07

the tests would be my go to for examples https://github.com/juxt/tick/blob/master/test/tick/alpha/interval_test.cljc#L266 not actually used intervals myself

dcj17:06:00

I am not sure what the issue is, but interval/union's docstring says "Merge multiple time-ordered sequences of disjoint intervals into a single sequence of time-ordered disjoint intervals.", and by looking at the source, it kinda seems like it is expecting one or more sequences of intervals, not one or more intervals. I'd first try (t.interval/union [a b]) and see what happens

Marius19:06:19

Ah ok, that’s it. Thank you very much! Next time i’ll check the tests before asking here 🙂