hare

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

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

time::chrono: standardise gps timescale code

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, 6 insertions(+), 10 deletions(-)

diff --git a/time/chrono/timescale.ha b/time/chrono/timescale.ha @@ -115,20 +115,16 @@ export const gps: timescale = timescale { from_tai = &conv_tai_utc, }; +// The constant offset between GPS-Time (Global Positioning System Time) and TAI +// (International Atomic Time). Used by [[gps]]. +def GPS_OFFSET: time::duration = -19 * time::SECOND; + fn conv_tai_gps(a: time::instant) (time::instant | time::error) = { - const b = time::instant { - sec = a.sec - 19, - nsec = a.nsec, - }; - return b; + return time::add(a, +GPS_OFFSET); }; fn conv_gps_tai(a: time::instant) (time::instant | time::error) = { - const b = time::instant { - sec = a.sec + 19, - nsec = a.nsec, - }; - return b; + return time::add(a, -GPS_OFFSET); };