Fork me on GitHub
#juxt
<
2021-03-31
>
dcj19:03:13

Tick question: How to I translate the following clojure.java-time code to tick?

(let [year 2020
        month 12
        day 1
        count 5]
    (take count (jtime/iterate jtime/plus
                               (jtime/local-date year month day)
                               (jtime/days 1))))


(#time/date "2020-12-01"
 #time/date "2020-12-02"
 #time/date "2020-12-03"
 #time/date "2020-12-04"
 #time/date "2020-12-05")

dcj19:03:01

The iterate part. "seq interval" ??

dominicm19:03:36

@dcj there's a (t/range) function you might need?

dcj19:03:52

ok, looking !

dcj19:03:26

@dominicm that's it, thank you!

dominicm19:03:11

@dcj looks like jtime/iterate is a convenience function, so you can just use clojure.core/iterate like so: (iterate #(t/+ % (t/new-durations 1 :days))) too.

dominicm19:03:23

But I think range is better for some reason I forget :)

dcj20:03:07

(let [year 2020
        month 12
        day 1
        num-days 5
        start (t/new-date year month day)
        end   (t/+ start (t/new-period num-days :days))
        ]
    (t/range start
             end
             (t/new-period 1 :days)))
Thanks!