Created
July 19, 2022 19:11
-
-
Save mikeananev/6afeb55fa87a05edc98107ca0d0b85c0 to your computer and use it in GitHub Desktop.
Calculate difference in days between two dates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn diff-between-days | |
| "Calculate difference in days between two dates." | |
| [date1 date2] | |
| (let [df (DateTimeFormatter/ofPattern "yyyy-MM-dd'T'HH:mm:ss.SSSxxxx" Locale/ROOT) | |
| d1 (if (string? date1) (ZonedDateTime/parse date1 df) date1) | |
| d2 (if (string? date2) (ZonedDateTime/parse date2 df) date2)] | |
| (.between ChronoUnit/DAYS d1 d2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment