hare

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

commit 0e8bdbd0fd6da8394aa8337b876fec2e2757d836
parent a4a1118680f3c77cb2329950ede4aab5fa91d9fe
Author: Byron Torres <b@torresjrjr.com>
Date:   Wed, 17 Nov 2021 01:28:13 +0000

fix now(), rename now() & new()

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

Diffstat:
Mdatetime/datetime.ha | 16+++++-----------
Mdatetime/format.ha | 4++--
2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/datetime/datetime.ha b/datetime/datetime.ha @@ -44,7 +44,7 @@ export fn new_moment( nsec: int, loc: locality, ) (chrono::moment | errors::invalid) = { - const dt = new_datetime(year, month, day, hour, min, sec, nsec, loc)?; + const dt = new(year, month, day, hour, min, sec, nsec, loc)?; const m = conv_datetime_moment(dt)?; return m; }; @@ -55,7 +55,7 @@ export fn new_moment( // datetime::new(1995, 07, 18, 9, 16, 0, 0, chrono::local) // // For alternative forms, assemble a datetime manually using the desired types. -export fn new_datetime( +export fn new( year: int, month: int, day: int, @@ -111,18 +111,12 @@ export fn now_moment() chrono::moment = { }; // Returns the current datetime -export fn now_datetime() datetime = { +export fn now() datetime = { const i = time::now(time::clock::REALTIME); const u = time::unix(i); const d = (u / 86400); - const ld = localdate { ... }; - conv_epochal_localdate(d, &ld, &localdate { - // TODO: reconcile, add new fields when ready - year = 0, - month = 0, - day = 0, - ... - }); + const ld = init_date(); + ld.epochal = d: int; const dt = datetime { date = ld, time = localtime { diff --git a/datetime/format.ha b/datetime/format.ha @@ -89,7 +89,7 @@ export fn fmttime(h: io::handle, format: str, dt: *datetime) (size | errors::inv }; escaped = false; - let new = switch (r) { + let s = switch (r) { case 'a' => yield WEEKDAYS_SHORT[weekday(dt) - 1]; case 'A' => @@ -210,7 +210,7 @@ export fn fmttime(h: io::handle, format: str, dt: *datetime) (size | errors::inv strio::appendrune(h, r)?; continue; }; - n += strio::concat(h, new)?; + n += strio::concat(h, s)?; }; return n; };