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