diff --git a/member-record.scm b/member-record.scm index 3ea0022..53fb387 100644 --- a/member-record.scm +++ b/member-record.scm @@ -154,6 +154,13 @@ (loop (cdr fmtl) (cons (make-string 1 (car fmtl)) resl))))))) + ;; Returns the number of months the user is suspended. Zero if not + ;; suspended. + (define (member-suspended-month mr) + (if (member-suspended? mr) + 1 + 0)) + ;; Performs module self-tests. (define (member-record-tests!) (run-tests diff --git a/period.scm b/period.scm index 4eca1ea..8598839 100644 --- a/period.scm +++ b/period.scm @@ -134,6 +134,17 @@ (map period->string ps) ", ")) + ;; Finds a period the month marthes and returns it. If no period + ;; matches, it returns #f. + (define (periods-match ps . ml) + (let ((m (if (null? ml) (*current-month*) (car ml)))) + (let loop ((ps ps)) + (if (null? ps) + #f + (if (month-in-period? (car ps) m) + (car ps) + (loop (cdr ps))))))) + ;; Performs self-tests of the period module. (define (period-tests!) (run-tests @@ -184,6 +195,13 @@ (periods->string '(((2022 1) . (2022 4)) ((2022 12). (2023 2)))) "2022-01..2022-04, 2022-12..2023-02") + (test-false periods-match (periods-match '(((2022 1) . (2022 4)) + ((2022 12). (2023 2))) + '(2022 5))) + (test-equal? periods-match (periods-match '(((2022 1) . (2022 4)) + ((2022 12). (2023 2))) + '(2022 2)) + '((2022 1) . (2022 4))) )) )