[date-utilities] tidy up gnc:make-date-interval-list

This commit is contained in:
Christopher Lam 2019-07-24 23:44:24 +08:00
parent 9e3aca2ea9
commit 7e9ec00906

View File

@ -249,6 +249,8 @@
(define (gnc:make-date-interval-list startdate enddate incr)
(define month-delta
(assv-ref MonthDeltas incr))
(define (make-interval from to)
(list from (if (< to enddate) (decdate to SecDelta) enddate)))
(let loop ((result '())
(date startdate)
(idx 0))
@ -258,20 +260,12 @@
(month-delta
(let* ((curr (incdate-months startdate (* month-delta idx)))
(next (incdate-months startdate (* month-delta (1+ idx)))))
(loop (cons (list curr
(if (< next enddate)
(decdate next SecDelta)
enddate))
result)
(loop (cons (make-interval curr next) result)
next
(1+ idx))))
(else
(let ((next (incdate date incr)))
(loop (cons (list date
(if (< next enddate)
(decdate next SecDelta)
enddate))
result)
(loop (cons (make-interval date next) result)
next
(1+ idx)))))))