hare

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

commit c6510afaf6e2cebebc6486f833235a17a4359a6b
parent ad46c132720c1cbcdd8cac9f19fa0f18dedb0ab1
Author: Byron Torres <b@torresjrjr.com>
Date:   Sun,  9 Jan 2022 23:05:54 +0000

add chrono::to_instant()

Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Mtime/chrono/chronology.ha | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/time/chrono/chronology.ha b/time/chrono/chronology.ha @@ -45,6 +45,16 @@ export fn from_instant(i: time::instant, loc: locality) moment = { return m; }; +// Creates a new [[time::instant]] from a [[moment]] +export fn to_instant(m: moment) time::instant = { + const daysec = (m.loc.daylength / time::SECOND); + const i = time::instant { + sec = (m.date: i64 * daysec) + (m.time / time::SECOND), + nsec = m.time % time::SECOND, + }; + return i; +}; + // The temporal length of a day on Earth. // Interpreted with an appropriate timescale like UTC, TAI, GPS. export def EARTH_DAY: time::duration = 86400 * time::SECOND;