From ae8b994a399cf0eed174ee6e9d17b22220aa55c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Mon, 27 Mar 2023 17:26:58 +0200 Subject: [PATCH] Finish period conversion. --- period.scm | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/period.scm b/period.scm index 8a6af1a..59c2f5d 100644 --- a/period.scm +++ b/period.scm @@ -125,9 +125,9 @@ (let ((m (if (null? ml) (*current-month*) (car ml)))) - (and (or (not (cdr p)) - (monthstring p) (sprintf "~A..~A" - (month->string (car p)) - (month->string (cdr p)))) + (month->string (period-since p)) + (month->string (period-before p)))) ;; Returns a string representing a list of periods. (define (periods->string ps) @@ -199,35 +199,35 @@ ((2023 1) (2023 4) #f #f))) 10) (test-true month-in-period? - (month-in-period? '((2022 1) . (2022 4)) '(2022 3))) + (month-in-period? '((2022 1) (2022 4) #f #f) '(2022 3))) (test-false month-in-period? - (month-in-period? '((2022 1) . (2022 4)) '(2022 5))) + (month-in-period? '((2022 1) (2022 4) #f #f) '(2022 5))) (test-true month-in-periods? - (month-in-periods? '(((2022 1) . (2022 4)) - ((2023 5) . (2023 10))) + (month-in-periods? '(((2022 1) (2022 4) #f #f) + ((2023 5) (2023 10) #f #f)) '(2022 3))) (test-true month-in-periods? - (month-in-periods? '(((2022 1) . (2022 4)) - ((2023 5) . (2023 10))) + (month-in-periods? '(((2022 1) (2022 4) #f #f) + ((2023 5) (2023 10) #f #f)) '(2023 7))) (test-false month-in-periods? - (month-in-periods? '(((2022 1) . (2022 4)) - ((2023 5) . (2023 10))) + (month-in-periods? '(((2022 1) (2022 4) #f #f) + ((2023 5) (2023 10) #f #f)) '(2022 10))) (test-equal? period->string - (period->string '((2022 1) . (2022 4))) + (period->string '((2022 1) (2022 4) #f #f)) "2022-01..2022-04") (test-equal? periods->string - (periods->string '(((2022 1) . (2022 4)) - ((2022 12). (2023 2)))) + (periods->string '(((2022 1) (2022 4) #f #f) + ((2022 12) (2023 2) #f #f))) "2022-01..2022-04, 2022-12..2023-02") - (test-false periods-match (periods-match '(((2022 1) . (2022 4)) - ((2022 12). (2023 2))) + (test-false periods-match (periods-match '(((2022 1) (2022 4) #f #f) + ((2022 12) (2023 2) #f #f)) '(2022 5))) - (test-equal? periods-match (periods-match '(((2022 1) . (2022 4)) - ((2022 12). (2023 2))) + (test-equal? periods-match (periods-match '(((2022 1) (2022 4) #f #f) + ((2022 12) (2023 2) #f #f)) '(2022 2)) - '((2022 1) . (2022 4))) + '((2022 1) (2022 4) #f #f)) )) )