From f50f97fb8e050cc050c33ccf0d851b2437def68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 1 Mar 2022 03:57:53 +0100 Subject: Remove case*. It has its uses, but like others, its extra weight. --- module/datetime.scm | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'module/datetime.scm') diff --git a/module/datetime.scm b/module/datetime.scm index 81135d39..fce248e1 100644 --- a/module/datetime.scm +++ b/module/datetime.scm @@ -16,7 +16,6 @@ -> ->> swap - case* set label span-upto @@ -365,17 +364,16 @@ (not (zero? (remainder year 100)))))) ;; Returns number of days month for a given date. Just looks at the year and month components. -(define (days-in-month date) - (case* (month date) - ((jan mar may jul aug oct dec) 31) - ((apr jun sep nov) 30) - ((feb) - (if (leap-year? (year date)) - 29 28)) - (else (scm-error 'out-of-range "days-in-month" - "No month number ~a (~a)" - (list (month date) date) - #f)))) +(define-public (days-in-month date) + (define m (month date)) + (cond ((memv m (list jan mar may jul aug oct dec)) 31) + ((memv m (list apr jun sep nov)) 30) + ((and (= m feb) (leap-year? (year date))) 29) + ((= m feb) 28) + (else (scm-error 'out-of-range "days-in-month" + "No month number ~a (~a)" + (list (month date) date) + #f)))) (define (days-in-year date) (if (leap-year? (year date)) -- cgit v1.2.3