From 947a1c1373cd834513356dbb32b20c3d425af45c Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 6 Oct 2025 22:23:14 +0100 Subject: [PATCH] return utc as (values seconds nanos) fractional seconds is just inviting too much fun with floating point error --- pkgs/anoia/tai64.fnl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/anoia/tai64.fnl b/pkgs/anoia/tai64.fnl index d19153a..74d2045 100644 --- a/pkgs/anoia/tai64.fnl +++ b/pkgs/anoia/tai64.fnl @@ -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 }