Create member calendar.

This commit is contained in:
Dominik Pantůček 2023-03-27 20:52:04 +02:00
parent a729d2f991
commit 6c8d2c8dbd
5 changed files with 51 additions and 15 deletions

View file

@ -137,9 +137,13 @@
(error 'month-diff "Second argument is not a valid month" t))
(error 'month-diff "First argument is not a valid month" f)))
;; Returns a month n months after the month m.
(define (month-add m n)
(let ((mi (+ (* 12 (car m)) (cadr m) n -1)))
;; Returns a month n months after the month m. The number n defaults
;; to 1.
(define (month-add m . ns)
(let* ((n (if (null? ns)
1
(car ns)))
(mi (+ (* 12 (car m)) (cadr m) n -1)))
(list (quotient mi 12)
(+ (remainder mi 12) 1))))