hare

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

commit b7d4281445923daef30f4d2002b2e0608251b534
parent 15fce5c0093efb02b6de29cca4e9a629aa4c94ad
Author: Byron Torres <b@torresjrjr.com>
Date:   Mon, 20 Dec 2021 02:58:19 +0000

use locality union

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

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

diff --git a/datetime/datetime.ha b/datetime/datetime.ha @@ -29,7 +29,7 @@ fn init() datetime = datetime { date = 0, time = 0, zone = chrono::zone{ ... }, - tz = &chrono::local, + loc = &chrono::local, era = void, year = void, @@ -61,13 +61,13 @@ export fn new( sec: int, nsec: int, zoffset: chrono::zoffset, - tz: (*chrono::timezone | void), + loc: (*chrono::timezone | void), ) (datetime | errors::invalid) = { const dt = datetime { date = calc_epochal_from_ymd(year, month, day)?, time = calc_time_from_hmsn(hour, min, sec, nsec)?, zone = chrono::zone{ zoffset = zoffset, ... }, - tz = if (tz is void) &chrono::local else tz: *chrono::timezone, + loc = if (loc is void) &chrono::local else loc: *chrono::timezone, era = void, year = year, @@ -101,7 +101,7 @@ export fn now() datetime = { // /etc/localtime or $TZ? How to determine the system's // timescale? Assuming UTC may be sufficient. zone = chrono::zone{ ... }, - tz = &chrono::local, + loc = &chrono::local, era = void, year = caldate.0, diff --git a/datetime/timezone.ha b/datetime/timezone.ha @@ -13,7 +13,7 @@ export fn tzdb(name: str) chrono::timezone = { // // "Europe/Amsterdam" timezone -export const TZ_Europe_Amsterdam: chrono::tzalias = chrono::tzalias { +export const TZ_Europe_Amsterdam: chrono::tzlink = chrono::tzlink { name = "Europe/Amsterdam", tz = &TZ_CET, }; diff --git a/time/chrono/chronology.ha b/time/chrono/chronology.ha @@ -5,7 +5,7 @@ export type moment = struct { date: epochal, time: time::duration, zone: zone, - tz: *timezone, + loc: locality, }; // An ordinal day on earth since the calendar epoch (zeroth day) 1970-01-01 diff --git a/time/chrono/timezone.ha b/time/chrono/timezone.ha @@ -1,5 +1,7 @@ use time; +export type locality = (*timezone | *tzlink); + // The zoneinfo of a datetime export type zoneinfo = struct { zabbrev: str, // %Z @@ -32,7 +34,7 @@ export type zonetran = struct { }; // An alias to a timezone -export type tzalias = struct { +export type tzlink = struct { name: str, tz: *timezone, };