diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-01 03:57:53 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-07 21:14:09 +0200 |
commit | f50f97fb8e050cc050c33ccf0d851b2437def68c (patch) | |
tree | 84abc4ae86f7aacb4e2ea9924acef0e64941e0a7 /module/datetime.scm | |
parent | Move each imported symbol to own line for easier removal. (diff) | |
download | calp-f50f97fb8e050cc050c33ccf0d851b2437def68c.tar.gz calp-f50f97fb8e050cc050c33ccf0d851b2437def68c.tar.xz |
Remove case*.
It has its uses, but like others, its extra weight.
Diffstat (limited to '')
-rw-r--r-- | module/datetime.scm | 22 |
1 files changed, 10 insertions, 12 deletions
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)) |