return utc as (values seconds nanos)
fractional seconds is just inviting too much fun with floating point error
This commit is contained in:
@@ -65,14 +65,15 @@
|
|||||||
nil))
|
nil))
|
||||||
|
|
||||||
(fn to-utc [tai]
|
(fn to-utc [tai]
|
||||||
(+ (- tai.s (leap-seconds tai.s)) (/ tai.n 1e9)))
|
(values (- tai.s (leap-seconds tai.s)) tai.n))
|
||||||
|
|
||||||
(define-tests
|
(define-tests
|
||||||
(expect=
|
(expect=
|
||||||
(from-timestamp "@4000000068e2f0d3257dc09b")
|
(from-timestamp "@4000000068e2f0d3257dc09b")
|
||||||
{:s 1759703251 :n 628998299})
|
{:s 1759703251 :n 628998299})
|
||||||
|
|
||||||
(expect= (to-utc (from-timestamp "@4000000068e2f0d3257dc09b"))
|
(let [(s n) (to-utc (from-timestamp "@4000000068e2f0d3257dc09b"))]
|
||||||
1759703214.628998299))
|
(expect= [s n] [1759703214 628998299]))
|
||||||
|
)
|
||||||
|
|
||||||
{ : from-timestamp : to-utc }
|
{ : from-timestamp : to-utc }
|
||||||
|
Reference in New Issue
Block a user