hare

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

commit 45cdf2806c475ea69d42bd988cb29176b8954d89
parent 2fad2a55a83b08c4bf7e4f94e9bb0f4b3662ad8a
Author: Byron Torres <b@torresjrjr.com>
Date:   Tue,  1 Feb 2022 00:34:40 +0000

rm datetime::print_period()

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

Diffstat:
Mdatetime/arithmetic.ha | 24------------------------
Mdatetime/format.ha | 5+++++
2 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/datetime/arithmetic.ha b/datetime/arithmetic.ha @@ -21,22 +21,6 @@ export type period = struct { nanoseconds: i64, }; -// Prints to stdout the representation of a period. -// -// TODO: This is a debug utility. Remove this in favour of changing format() to -// accept arguments of type (datetime | period), using the "intervals" standard -// representation provided by ISO 8601. -// -// See https://en.wikipedia.org/wiki/ISO_8601#Time_intervals -export fn print_period(p: period) void = { - fmt::printfln( - "eras: {}\nyears: {}\nmonths: {}\nweeks: {}\ndays: {}\n" - "hours: {}\nminutes: {}\nseconds: {}\nnanoseconds: {}", - p.eras, p.years, p.months, p.weeks, p.days, p.hours, - p.minutes, p.seconds, p.nanoseconds - )!; -}; - // Specifies behaviour during calendar arithmetic // // * DEFAULT @@ -874,14 +858,6 @@ fn absi(n: i64) i64 = { const p = cases[i].0; const expected = cases[i].1; const actual = add(d, calculus::DEFAULT, p); - if (!eq(actual, expected)) { - fmt::printfln("attempting to add:")!; - print_period(p); - fmt::printfln("expected {}", - format("%F %T.%N", &expected)!)!; - fmt::printfln("was {}\n", - format("%F %T.%N", &actual)!)!; - }; assert(eq(actual, expected), "addition miscalculation"); }; }; diff --git a/datetime/format.ha b/datetime/format.ha @@ -50,6 +50,11 @@ def MONTHS_SHORT: [_]str = [ // TODO: Document specifiers (%Y, %m, etc) used here, in README or otherwise. +// TODO: Make format() accept parameters of type (datetime | period), using the +// "intervals" standard representation provided by ISO 8601? +// +// See https://en.wikipedia.org/wiki/ISO_8601#Time_intervals + // Parses a datetime string into a [[builder]], using a "layout" format string // with a subset of specifiers from POSIX strptime(3). Partial, incremental // parsing is possible.