From d2ad2fdebb7cda202eab52c6c9ea9c09bcf65661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Mon, 27 Mar 2023 17:23:12 +0200 Subject: [PATCH] Start using new period representation. --- period.scm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/period.scm b/period.scm index a792e9c..8a6af1a 100644 --- a/period.scm +++ b/period.scm @@ -79,7 +79,7 @@ (if (null? l) (list #t (if cb - (reverse (cons (cons cb #f) ps)) + (reverse (cons (make-period cb #f) ps)) (reverse ps)) "" -1) @@ -97,7 +97,7 @@ (if (eq? mtype rmt) (if cb (loop (cdr l) - (cons (cons cb month) ps) + (cons (make-period cb month) ps) #f) (loop (cdr l) ps @@ -110,8 +110,8 @@ ;; Returns duration of period in months. Start is included, end is ;; not. The period contains the month just before the specified end. (define (period->duration p) - (let* ((b (car p)) - (e (cdr p)) + (let* ((b (period-since p)) + (e (period-before p)) (e- (if e e (*current-month*)))) (month-diff b e-))) @@ -176,27 +176,27 @@ (period-markers->periods '((start (2022 3)) (stop (2022 10)) (start (2023 1)) (stop (2023 4)))) '(#t - (((2022 3) . (2022 10)) - ((2023 1) . (2023 4))) + (((2022 3) (2022 10) #f #f) + ((2023 1) (2023 4) #f #f)) "" -1)) (test-equal? period-markers->periods-open (period-markers->periods '((start (2022 3)) (stop (2022 10)) (start (2023 1)) (stop (2023 4)) (start (2023 5)))) '(#t - (((2022 3) . (2022 10)) - ((2023 1) . (2023 4)) - ((2023 5) . #f)) + (((2022 3) (2022 10) #f #f) + ((2023 1) (2023 4) #f #f) + ((2023 5) #f #f #f)) "" -1)) (test-eq? period-duration - (period->duration '((2023 1) . (2023 4))) 3) + (period->duration '((2023 1) (2023 4) #f #f)) 3) (parameterize ((*current-month* (list 2023 4))) (test-eq? period-duration - (period->duration '((2023 1) . #f)) 3)) + (period->duration '((2023 1) #f #f #f)) 3)) (test-eq? periods-duration - (periods-duration '(((2022 3) . (2022 10)) - ((2023 1) . (2023 4)))) + (periods-duration '(((2022 3) (2022 10) #f #f) + ((2023 1) (2023 4) #f #f))) 10) (test-true month-in-period? (month-in-period? '((2022 1) . (2022 4)) '(2022 3)))