hare

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

commit b7aeba2e0f10b964a75c6936413ac350e18ac230
parent d0c9cad01e32fb987979e3560ba38aefc3e95043
Author: Byron Torres <b@torresjrjr.com>
Date:   Tue, 24 May 2022 04:00:19 +0100

time::chrono: change new() parameter order

The locality is now the first parameter. This is consistent with the
rest of the functionality like {time::chrono,datetime}::in() and
datetime::new(), and reinforces the important notion of datetimes and
moments belonging to a locality first.

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

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

diff --git a/time/chrono/chronology.ha b/time/chrono/chronology.ha @@ -26,7 +26,11 @@ export type moment = struct { export type epochal = i64; // Creates a new [[moment]]. -export fn new(date: epochal, time: time::duration, loc: locality) (moment | invalid) = { +export fn new( + loc: locality, + date: epochal, + time: time::duration, +) (moment | invalid) = { if (time > loc.daylength) { return invalid; }; @@ -46,7 +50,7 @@ export fn from_instant(i: time::instant, loc: locality) moment = { const d = i.sec / daysec; const t = (i.sec % daysec) * time::SECOND + i.nsec * time::NANOSECOND; assert(t < loc.daylength, "Internal error: time excedes daylength"); - return new(d, t, loc)!; + return new(loc, d, t)!; }; // Creates a new [[time::instant]] from a [[moment]]. diff --git a/time/chrono/timezone.ha b/time/chrono/timezone.ha @@ -72,7 +72,7 @@ type tzname = struct { // Creates an equivalent [[moment]] with a different [[locality]]. export fn in(loc: locality, m: moment) moment = { assert(m.time < loc.daylength, "Internal error: time excedes daylength"); - return new(m.date, m.time, loc)!; // resets .zone + return new(loc, m.date, m.time)!; // resets .zone }; export fn transform(m: moment, zo: time::duration) moment = {