Improve period checking with current month.
This commit is contained in:
parent
798cfe318c
commit
4c5b3db247
2 changed files with 31 additions and 13 deletions
28
period.scm
28
period.scm
|
@ -99,19 +99,25 @@
|
|||
|
||||
;; True if month belongs to given month period - start inclusive, end
|
||||
;; exclusive.
|
||||
(define (month-in-period? p m)
|
||||
(and (month<? m (cdr p))
|
||||
(not (month<? m (car p)))))
|
||||
(define (month-in-period? p . ml)
|
||||
(let ((m (if (null? ml)
|
||||
(*current-month*)
|
||||
(car ml))))
|
||||
(and (month<? m (cdr p))
|
||||
(not (month<? m (car p))))))
|
||||
|
||||
;; Returns true if given month is in at least one of the periods
|
||||
;; given.
|
||||
(define (month-in-periods? ps m)
|
||||
(let loop ((ps ps))
|
||||
(if (null? ps)
|
||||
#f
|
||||
(if (month-in-period? (car ps) m)
|
||||
#t
|
||||
(loop (cdr ps))))))
|
||||
;; given. Defaults to current month.
|
||||
(define (month-in-periods? ps . ml)
|
||||
(let ((m (if (null? ml)
|
||||
(*current-month*)
|
||||
(car ml))))
|
||||
(let loop ((ps ps))
|
||||
(if (null? ps)
|
||||
#f
|
||||
(if (month-in-period? (car ps) m)
|
||||
#t
|
||||
(loop (cdr ps)))))))
|
||||
|
||||
;; Returns string representing a month period with possibly open end.
|
||||
(define (period->string p)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue