Skip to content

Commit

Permalink
duration function works on interval with LocalDate bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
henryw374 committed Sep 7, 2023
1 parent c679721 commit 6963129
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/tick/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@
(defn beginning "the beginning of the range of ITimeSpan v or v" [v] (p/beginning v))
(defn end "the end of the range of ITimeSpan v or v" [v] (p/end v))

(defn duration "return duration contained within the range of ITimeSpan 'x', which can be a year, year-month or date " [x]
(cljc.java-time.duration/between (beginning x) (end x)))
(defn duration "return Duration or Period (whichever appropriate based on type) contained within the range of ITimeSpan x" [x]
(between (beginning x) (end x)))

;; Periods

Expand Down
4 changes: 3 additions & 1 deletion test/tick/api_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,9 @@
(is (= (t/new-duration 1e9 :nanos) (t/new-duration 1 :seconds)))
(is (= (t/new-duration 1000 :millis) (t/new-duration 1 :seconds)))

(is (= (t/new-duration 24 :hours) (t/duration (t/tomorrow)))))
(is (= (t/of-hours 24) (t/duration (t/date))))
(is (= (t/of-days 1) (t/duration {:tick/beginning (t/date)
:tick/end (t/inc (t/date))}))))

;; Durations. Convenience functions to create durations of specific
;; units.
Expand Down

0 comments on commit 6963129

Please sign in to comment.