Finish period conversion.
This commit is contained in:
parent
d2ad2fdebb
commit
ae8b994a39
1 changed files with 21 additions and 21 deletions
42
period.scm
42
period.scm
|
@ -125,9 +125,9 @@
|
||||||
(let ((m (if (null? ml)
|
(let ((m (if (null? ml)
|
||||||
(*current-month*)
|
(*current-month*)
|
||||||
(car ml))))
|
(car ml))))
|
||||||
(and (or (not (cdr p))
|
(and (or (not (period-before p))
|
||||||
(month<? m (cdr p)))
|
(month<? m (period-before p)))
|
||||||
(not (month<? m (car p))))))
|
(not (month<? m (period-since p))))))
|
||||||
|
|
||||||
;; 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.
|
||||||
|
@ -145,8 +145,8 @@
|
||||||
;; Returns string representing a month period with possibly open end.
|
;; Returns string representing a month period with possibly open end.
|
||||||
(define (period->string p)
|
(define (period->string p)
|
||||||
(sprintf "~A..~A"
|
(sprintf "~A..~A"
|
||||||
(month->string (car p))
|
(month->string (period-since p))
|
||||||
(month->string (cdr p))))
|
(month->string (period-before p))))
|
||||||
|
|
||||||
;; Returns a string representing a list of periods.
|
;; Returns a string representing a list of periods.
|
||||||
(define (periods->string ps)
|
(define (periods->string ps)
|
||||||
|
@ -199,35 +199,35 @@
|
||||||
((2023 1) (2023 4) #f #f)))
|
((2023 1) (2023 4) #f #f)))
|
||||||
10)
|
10)
|
||||||
(test-true month-in-period?
|
(test-true month-in-period?
|
||||||
(month-in-period? '((2022 1) . (2022 4)) '(2022 3)))
|
(month-in-period? '((2022 1) (2022 4) #f #f) '(2022 3)))
|
||||||
(test-false month-in-period?
|
(test-false month-in-period?
|
||||||
(month-in-period? '((2022 1) . (2022 4)) '(2022 5)))
|
(month-in-period? '((2022 1) (2022 4) #f #f) '(2022 5)))
|
||||||
(test-true month-in-periods?
|
(test-true month-in-periods?
|
||||||
(month-in-periods? '(((2022 1) . (2022 4))
|
(month-in-periods? '(((2022 1) (2022 4) #f #f)
|
||||||
((2023 5) . (2023 10)))
|
((2023 5) (2023 10) #f #f))
|
||||||
'(2022 3)))
|
'(2022 3)))
|
||||||
(test-true month-in-periods?
|
(test-true month-in-periods?
|
||||||
(month-in-periods? '(((2022 1) . (2022 4))
|
(month-in-periods? '(((2022 1) (2022 4) #f #f)
|
||||||
((2023 5) . (2023 10)))
|
((2023 5) (2023 10) #f #f))
|
||||||
'(2023 7)))
|
'(2023 7)))
|
||||||
(test-false month-in-periods?
|
(test-false month-in-periods?
|
||||||
(month-in-periods? '(((2022 1) . (2022 4))
|
(month-in-periods? '(((2022 1) (2022 4) #f #f)
|
||||||
((2023 5) . (2023 10)))
|
((2023 5) (2023 10) #f #f))
|
||||||
'(2022 10)))
|
'(2022 10)))
|
||||||
(test-equal? period->string
|
(test-equal? period->string
|
||||||
(period->string '((2022 1) . (2022 4)))
|
(period->string '((2022 1) (2022 4) #f #f))
|
||||||
"2022-01..2022-04")
|
"2022-01..2022-04")
|
||||||
(test-equal? periods->string
|
(test-equal? periods->string
|
||||||
(periods->string '(((2022 1) . (2022 4))
|
(periods->string '(((2022 1) (2022 4) #f #f)
|
||||||
((2022 12). (2023 2))))
|
((2022 12) (2023 2) #f #f)))
|
||||||
"2022-01..2022-04, 2022-12..2023-02")
|
"2022-01..2022-04, 2022-12..2023-02")
|
||||||
(test-false periods-match (periods-match '(((2022 1) . (2022 4))
|
(test-false periods-match (periods-match '(((2022 1) (2022 4) #f #f)
|
||||||
((2022 12). (2023 2)))
|
((2022 12) (2023 2) #f #f))
|
||||||
'(2022 5)))
|
'(2022 5)))
|
||||||
(test-equal? periods-match (periods-match '(((2022 1) . (2022 4))
|
(test-equal? periods-match (periods-match '(((2022 1) (2022 4) #f #f)
|
||||||
((2022 12). (2023 2)))
|
((2022 12) (2023 2) #f #f))
|
||||||
'(2022 2))
|
'(2022 2))
|
||||||
'((2022 1) . (2022 4)))
|
'((2022 1) (2022 4) #f #f))
|
||||||
))
|
))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue