Fork me on GitHub
#juxt
<
2022-08-19
>
Pedro Boschi14:08:35

In tick, is it possible to get the total number of "days" (or other unit) present in a Period ? For example: If I try this:

(time/days (time/between (time/date "2022-08-19") "2022-09-20"))
it returns just 1 However if I call Java Time directly, like this:
(.between java.time.temporal.ChronoUnit/DAYS (time/date "2022-08-19") (time/date "2022-09-20"))
we get the correct answer, which is 32.... Is there a tick function to get the desired answer "32"?

henryw37414:08:56

it's not possible to get the total number of days in a period, bc e.g. a period of 1 year, 1 month and 1 day is abstract. a year can have 365 days or 366 etc

henryw37414:08:12

there is no direct tick equivalent to the java.time code. you can do it with cljc.java-time though:

(ns time-lib-comparison.java-time
  (:require [cljc.java-time.local-date :as date]
            [cljc.java-time.temporal.chrono-unit :as cu]))

(defn interval-calc [event-date]
  (-> cu/days (cu/between (date/now) (date/parse event-date))))

henryw37414:08:24

tick already depends on that