diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-01 02:55:27 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-01 02:55:27 +0100 |
commit | cbf0cf6f61bbe3cd4a80b48ca3fa3135106e371e (patch) | |
tree | c47e0574a1270fd745beb2bf1dd83d2628dd9003 /module/datetime.scm | |
parent | Add unit test for days-in-interval. (diff) | |
download | calp-cbf0cf6f61bbe3cd4a80b48ca3fa3135106e371e.tar.gz calp-cbf0cf6f61bbe3cd4a80b48ca3fa3135106e371e.tar.xz |
Remove with-stream macro.
It was an extra (rather complicated) macro to support, which had 2
unresolved TODO:s, and made the resulting code hard to read since it
wasn't immediately apparent which procedures where replaced by their
stream counterparts.
The only using code was rewritten using a threading macro, which is way
more readable.
Diffstat (limited to 'module/datetime.scm')
-rw-r--r-- | module/datetime.scm | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/module/datetime.scm b/module/datetime.scm index 9657a803..d5ef03b1 100644 --- a/module/datetime.scm +++ b/module/datetime.scm @@ -10,12 +10,10 @@ :use-module (srfi srfi-9 gnu) :use-module ((hnh util) - :select (vector-last define*-public set! -> swap case* set + :select (vector-last define*-public set! -> ->> swap case* set span-upto let* set->)) :use-module (srfi srfi-41) - :use-module ((srfi srfi-41 util) - :select (with-streams)) :use-module (ice-9 i18n) :use-module (ice-9 format) :use-module (ice-9 regex) @@ -538,12 +536,12 @@ ;; The amount of days in the given interval, both end pointts inclusive (define-public (days-in-interval start-date end-date) (let ((diff (date-difference (date+ end-date (date day: 1)) start-date))) - (with-streams - (fold + (day diff) - (map days-in-month - (take (+ (month diff) - (* 12 (year diff))) - (month-stream start-date))))))) + (->> (month-stream start-date) + (stream-take (+ (month diff) + (* 12 (year diff)))) + (stream-map days-in-month) + (stream-fold + (day diff))))) + ;; Day from start of the year, so 1 feb would be day 32. ;; Also known as Julian day. |