hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 4fa994f2588ef381dbfe0c3f78e8b0341c7e12d9
parent 1d46a797a9325790bb3cb8fa26a3d3b25783e38d
Author: Byron Torres <b@torresjrjr.com>
Date:   Tue, 24 May 2022 04:00:24 +0100

time::chrono: fix tt timescale converters

References: https://todo.sr.ht/~sircmpwn/hare/642
Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Mtime/chrono/timescale.ha | 16+++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/time/chrono/timescale.ha b/time/chrono/timescale.ha @@ -144,22 +144,16 @@ export const tt: timescale = timescale { from_tai = &conv_tai_tt, }; -def TT_OFFSET: time::duration = (32.184 * time::SECOND: f64): time::duration; +// The constant offset between TT (Terrestrial Time) and TAI (International +// Atomic Time). Used by [[tt]]. +def TT_OFFSET: time::duration = 32184 * time::MILLISECOND; // 32.184 seconds fn conv_tai_tt(a: time::instant) (time::instant | time::error) = { - const b = time::instant { - sec = a.sec + (TT_OFFSET / time::SECOND), - nsec = a.nsec + (TT_OFFSET % time::SECOND), - }; - return b; + return time::add(a, +TT_OFFSET); }; fn conv_tt_tai(a: time::instant) (time::instant | time::error) = { - const b = time::instant { - sec = a.sec - (TT_OFFSET / time::SECOND), - nsec = a.nsec + (TT_OFFSET % time::SECOND), - }; - return b; + return time::add(a, -TT_OFFSET); };