Format today as ISO date.
This commit is contained in:
parent
779aa80ba3
commit
09bce0be88
3 changed files with 34 additions and 7 deletions
|
@ -29,10 +29,13 @@
|
|||
util-time
|
||||
(
|
||||
current-util-milliseconds
|
||||
today/iso
|
||||
)
|
||||
|
||||
(import scheme
|
||||
(chicken time))
|
||||
(chicken time)
|
||||
(chicken time posix)
|
||||
(chicken format))
|
||||
|
||||
;; Compatibility wrapper
|
||||
(define (current-util-milliseconds)
|
||||
|
@ -46,5 +49,20 @@
|
|||
(else
|
||||
(current-process-milliseconds))))
|
||||
|
||||
;; Returns today as YYYY-MM-DD string
|
||||
(define (today/iso)
|
||||
(let ((d (seconds->local-time)))
|
||||
(format "~A-~A-~A"
|
||||
(number->string
|
||||
(+ 1900 (vector-ref d 5)))
|
||||
(substring
|
||||
(number->string
|
||||
(+ 101 (vector-ref d 4)))
|
||||
1)
|
||||
(substring
|
||||
(number->string
|
||||
(+ 100 (vector-ref d 3)))
|
||||
1))))
|
||||
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue