diff --git a/src/month.scm b/src/month.scm index 82f8087..e39c280 100644 --- a/src/month.scm +++ b/src/month.scm @@ -153,6 +153,14 @@ (list (quotient mi 12) (+ (remainder mi 12) 1)))) + ;; Converts ISO date to single month + (define (iso-date->month str) + (let* ((lst (string-split str "-")) + (year (car lst)) + (mon (cadr lst))) + (make-month (string->number year) + (string->number mon)))) + ;; Performs self-tests of the month module. (define (month-tests!) (run-tests @@ -177,6 +185,7 @@ (test-eq? month-diff (month-diff '(2023 1) '(2023 12)) 11) (test-eq? month-diff (month-diff '(2023 1) '(2022 2)) -11) (test-eq? month-add (month-add '(2023 1) 2) '(2023 3)) + (test-equal? iso-date->month (iso-date->month "2023-04-03") '(2023 4)) )) )