Parsing and formatting days.

This commit is contained in:
Dominik Pantůček 2023-05-11 10:04:05 +02:00
parent 46db92cc6b
commit 2e86d96b41

View file

@ -136,6 +136,12 @@
(apply make-cal-day (map string->number l)) (apply make-cal-day (map string->number l))
#f))) #f)))
;; Parses given string as either day or month
(define (parse-cal-day/month s)
(let ((d (string->cal-day s)))
(or d
(string->cal-month s))))
;; Module self-tests ;; Module self-tests
(define (cal-day-tests!) (define (cal-day-tests!)
(run-tests (run-tests
@ -172,6 +178,8 @@
(test-equal? string->cal-day (test-equal? string->cal-day
(string->cal-day "2023-05-11") (string->cal-day "2023-05-11")
(make-cal-day 2023 5 11)) (make-cal-day 2023 5 11))
(test-true parse-cal-day/month
(cal-day? (parse-cal-day/month "2023-05-11")))
)) ))
) )