dm3/clojure.java-time

Document how to compute differences between dates, e.g. nr. days between two dates

holyjak opened this issue · 2 comments

Should we just use .until or is there something built-in? In any case it would be worth documenting, finding out how many days / months / ... is between two days is common I'd believe.
Now I do

(.until (jt/local-date "2019-01-01") (jt/local-date "2019-02-13") (java.time.temporal.ChronoUnit/DAYS))

I have tried to do

(jt/as (jt/period (jt/local-date "2019-01-01") (jt/local-date "2019-02-13")) :days)
``` but it fails with "Period contains years or months"

I would like to know this information as well. Thanks for your solution, @holyjak ! It worked here.

dm3 commented

The readme provides an example of doing this:

(j/time-between :days (jt/local-date "2019-01-01") (jt/local-date "2019-02-13"))
43