hare

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

commit 4acb316c08e1354f8b213900695f1159836714d9
parent f480d18828457955f6cb29412f150dc7063b03fb
Author: Byron Torres <b@torresjrjr.com>
Date:   Fri, 28 Jan 2022 01:34:22 +0000

further comments and TODOs

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

Diffstat:
Mdatetime/README | 4----
Mdatetime/datetime.ha | 11+++++++----
Mdatetime/format.ha | 6++++--
Mdatetime/timezone.ha | 4++++
4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/datetime/README b/datetime/README @@ -29,10 +29,6 @@ in the [[time::olson]] module. TODO: Settle on consistent naming and language for localisation. "timezone" or "locality"? -TODO: Rename [[localize]] to something less confusing and more dangerous -sounding? Perhaps not export it? It's use is special case and often not -what users want. - Both formatting and parsing use a sensible subset of the POSIX format specifiers (see strptime(3)), and it is trivial to contruct your own textual representations with the functions herein. diff --git a/datetime/datetime.ha b/datetime/datetime.ha @@ -60,7 +60,7 @@ fn init() datetime = datetime { // // TODO: revise examples // -// zoffset is the zone offset from the normal timezone (in most cases, UTC0). +// zoffset is the zone offset from the normal timezone (in most cases, UTC_Z). // For example, the "Asia/Tokyo" timezone has a single zoffset of +9 hours, // but the "Australia/Sydney" timezone has zoffsets +10 hours and +11 hours, as // they observe Daylight Saving Time. @@ -75,11 +75,11 @@ fn init() datetime = datetime { // // - In the Europe/Amsterdam timezone, at 1995 March 26th, // the local time 02:30 was never observed, -// as the clock jumped forward 1 hour from 01:00 CET. +// as the clock jumped forward 1 hour from 02:00 CET to 03:00 CEST. // // - In the Europe/Amsterdam timezone, at 1995 September 24th, // the local time 02:30 was observed twice (00:30 UTC & 01:30 UTC), -// as the clock jumped back 1 hour from 02:00 CEST. +// as the clock jumped back 1 hour from 03:00 CEST to 02:00 CET. // // TODO: implement as described. export fn new( @@ -113,14 +113,17 @@ export fn new( }; // Returns a [[datetime]] of the immediate system time +// +// TODO: specify appropriate params like a time::clock and chrono::timezone. export fn now() datetime = { - // TODO: should the clock and timezone be choosable? const i = time::now(time::clock::REALTIME); const m = chrono::from_instant(i, chrono::local); return from_moment(m); }; // Creates a copy of a [[datetime]] +// +// TODO: remove, seems useless. export fn clone(dt: datetime) datetime = dt; // Creates a [[datetime]] from a [[chrono::moment]] diff --git a/datetime/format.ha b/datetime/format.ha @@ -47,9 +47,11 @@ def MONTHS_SHORT: [_]str = [ "Oct", "Nov", "Dec", ]; +// TODO: Document specifiers (%Y, %m, etc) used here, in README or otherwise. + // Parses a datetime string into a [[builder]], using a "layout" format string -// with specifiers from POSIX strptime(3). Partial, incremental parsing is -// allowed. +// with a subset of specifiers from POSIX strptime(3). Partial, incremental +// parsing is allowed. // // datetime::parse(&b, "%Y-%m-%d", "2038-01-19"); // datetime::parse(&b, "%H:%M:%S", "03:14:07"); diff --git a/datetime/timezone.ha b/datetime/timezone.ha @@ -15,6 +15,10 @@ export fn in(loc: chrono::locality, dt: datetime) datetime = { // // This is a utility function for use by other modules's internal calculations. // You probably shouldn't use this directly. +// +// TODO: Rename [[localize]] to something less confusing and more dangerous +// sounding? Perhaps not export it? It's use is special case and often not +// what users want. export fn localize(dt: datetime) datetime = { return from_moment(chrono::localize(to_moment(dt))); };