Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
holyjak opened this issue Nov 22, 2019 · 2 comments

Comments

@holyjak
Copy link
Contributor

holyjak commented Nov 22, 2019

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"
@lucasemmoreira
Copy link

lucasemmoreira commented Jun 26, 2020

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

@dm3
Copy link
Owner

dm3 commented Mar 21, 2021

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

@dm3 dm3 closed this as completed Mar 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants