Month formatting.
This commit is contained in:
parent
194615aa1d
commit
a05a7c24d8
1 changed files with 17 additions and 4 deletions
|
@ -115,8 +115,19 @@
|
|||
(define (string->month s)
|
||||
(list 2023 1))
|
||||
|
||||
(define (month->string m)
|
||||
"2023-01")
|
||||
;; Formats (valid) month as YYYY-MM string
|
||||
(define (month->string M)
|
||||
(let ((y (car s))
|
||||
(m (cadr s)))
|
||||
(if (or (< y 1000)
|
||||
(> y 9999)
|
||||
(< m 1)
|
||||
(> m 12))
|
||||
(error 'string->month "Invalid month" M)
|
||||
(sprintf "~A-~A~A"
|
||||
y
|
||||
(if (< m 10) " " "")
|
||||
m))))
|
||||
|
||||
(define (month=? m n)
|
||||
#f)
|
||||
|
@ -125,13 +136,15 @@
|
|||
#f)
|
||||
|
||||
(define (month-diff m n)
|
||||
; Inclusive?
|
||||
; Exclusive
|
||||
1)
|
||||
|
||||
(define (month-tests!)
|
||||
(display "[test] month ")
|
||||
;; Parsing
|
||||
;; Formatting
|
||||
(unit-test 'month->string (equal? (month->string '(2023 1)) "2023-01"))
|
||||
(unit-test 'month->string-bad-year (with-handler (lambda (x) #t) (month->string '(999 12)) #f))
|
||||
(unit-test 'month->string-bad-month (with-handler (lambda (x) #t) (month->string '(2023 13)) #f))
|
||||
;; Comparison less
|
||||
;; Comparison equal
|
||||
;; Comparison greater
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue