liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit f4b87430ea2e896257db8b058de3523536401e5d
parent c3d6ad7ad401367f0e58d5ef7cece7fe9dde132d
Author: Daniel Barlow <dan@telent.net>
Date:   Tue, 28 Oct 2025 23:28:33 +0000

tai64: write timestamp

Diffstat:
Mpkgs/anoia/tai64.fnl | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/pkgs/anoia/tai64.fnl b/pkgs/anoia/tai64.fnl @@ -74,6 +74,10 @@ {:s sec :n nano}) nil)) +(fn to-timestamp [{: s : n }] + (let [label (+ s (lshift 1 62))] + (string.format "@%16x%08x" label n))) + (fn to-unix [tai] (values (- tai.s (leap-seconds-tai tai.s)) tai.n)) @@ -91,6 +95,14 @@ (from-timestamp "@4000000068e2f0d3257dc09b") {:s 1759703251 :n 628998299}) + (expect= + (to-timestamp {:s 1759703251 :n 628998299}) + "@4000000068e2f0d3257dc09b") + + (expect= + (to-timestamp {:s -43200 :n 0}) + "@3fffffffffff574000000000") + (let [(s n) (to-unix (from-timestamp "@4000000068e2f0d3257dc09b"))] (expect= [s n] [1759703214 628998299])) @@ -111,4 +123,4 @@ ) -{ : from-timestamp : to-unix : from-unix } +{ : from-timestamp : to-timestamp : to-unix : from-unix }