return utc as (values seconds nanos)

fractional seconds is just inviting too much fun with floating point
error
This commit is contained in:
Daniel Barlow
2025-10-06 22:23:14 +01:00
parent 59eea64985
commit 947a1c1373

View File

@@ -65,14 +65,15 @@
nil))
(fn to-utc [tai]
(+ (- tai.s (leap-seconds tai.s)) (/ tai.n 1e9)))
(values (- tai.s (leap-seconds tai.s)) tai.n))
(define-tests
(expect=
(from-timestamp "@4000000068e2f0d3257dc09b")
{:s 1759703251 :n 628998299})
(expect= (to-utc (from-timestamp "@4000000068e2f0d3257dc09b"))
1759703214.628998299))
(let [(s n) (to-utc (from-timestamp "@4000000068e2f0d3257dc09b"))]
(expect= [s n] [1759703214 628998299]))
)
{ : from-timestamp : to-utc }