Format today as ISO date.

This commit is contained in:
Dominik Pantůček 2023-04-17 21:46:56 +02:00
parent 779aa80ba3
commit 09bce0be88
3 changed files with 34 additions and 7 deletions

View file

@ -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))))
)