Convert all months to cal-months.

This commit is contained in:
Dominik Pantůček 2023-05-21 20:50:40 +02:00
parent 82a4742914
commit 9ed3ef4423

View file

@ -186,10 +186,12 @@
(define (cal-month-in-period? p . ml) (define (cal-month-in-period? p . ml)
(let ((m (if (null? ml) (let ((m (if (null? ml)
(*current-month*) (*current-month*)
(car ml)))) (car ml)))
(and (or (not (cal-period-before p)) (before (cal-ensure-month (cal-period-before p) #t))
(cal-month<? m (cal-period-before p))) (since (cal-ensure-month (cal-period-since p))))
(not (cal-month<? m (cal-period-since p)))))) (and (or (not before)
(cal-month<? m before))
(not (cal-month<? m since)))))
;; Returns true if given month is in at least one of the periods ;; Returns true if given month is in at least one of the periods
;; given. Defaults to current month. ;; given. Defaults to current month.
@ -234,12 +236,13 @@
(prev #f)) (prev #f))
(if (null? lst) (if (null? lst)
(reverse (reverse
(cons (cons (make-cal-period (car prev) #f) (cons (cons (make-cal-period (apply make-cal-month (car prev)) #f)
(cdr prev)) (cdr prev))
res)) res))
(loop (cdr lst) (loop (cdr lst)
(if prev (if prev
(cons (cons (make-cal-period (car prev) (caar lst)) (cons (cons (make-cal-period (apply make-cal-month (car prev))
(apply make-cal-month (caar lst)))
(cdr prev)) (cdr prev))
res) res)
res) res)
@ -256,9 +259,11 @@
;; Wrapper that accepts either day or month and returns testable month ;; Wrapper that accepts either day or month and returns testable month
(define (cal-ensure-month v . stop?s) (define (cal-ensure-month v . stop?s)
(if v
(if (cal-month? v) (if (cal-month? v)
v v
(apply cal-day->month v stop?s))) (apply cal-day->month v stop?s))
#f))
;; Performs self-tests of the period module. ;; Performs self-tests of the period module.
(define (cal-period-tests!) (define (cal-period-tests!)