hare

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

commit 6aded183166b764a557b324d1dfd0bc58e3db08b
parent 825cd293af2d1b60e32f2fc7a2426d668eb1e030
Author: Autumn! <autumnull@posteo.net>
Date:   Wed, 15 Mar 2023 17:35:35 +0000

time::chrono: incorporate zone offset in in() and to_instant()

Signed-off-by: Autumn! <autumnull@posteo.net>

Diffstat:
Mtime/chrono/chronology.ha | 5+++--
Mtime/chrono/timezone.ha | 2+-
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/time/chrono/chronology.ha b/time/chrono/chronology.ha @@ -56,9 +56,10 @@ export fn from_instant(i: time::instant, loc: locality) moment = { // Creates a new [[time::instant]] from a [[moment]]. export fn to_instant(m: moment) time::instant = { const daysec = (m.loc.daylength / time::SECOND); + const t = m.time + m.zone.zoffset; const i = time::instant { - sec = (m.date: i64 * daysec) + (m.time / time::SECOND), - nsec = m.time % time::SECOND, + sec = (m.date: i64 * daysec) + (t / time::SECOND), + nsec = t % time::SECOND, }; return i; }; diff --git a/time/chrono/timezone.ha b/time/chrono/timezone.ha @@ -96,7 +96,7 @@ export fn in(loc: locality, m: moment) moment = { }; assert(m.time < loc.daylength, "Internal error: time excedes daylength"); - return new(loc, m.date, m.time)!; // resets .zone + return new(loc, m.date, m.time + m.zone.zoffset)!; // resets .zone }; export fn transform(m: moment, zo: time::duration) moment = {