hare

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

commit 9bbbe783ab8857106bd4cd449501babb581a981f
parent 72c8619653a7c17f0ca073f2e6229ecd13c9c5da
Author: Vlad-Stefan Harbuz <vlad@vladh.net>
Date:   Fri,  7 Jan 2022 17:27:46 +0100

add print_period()

Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Mdatetime/arithmetic.ha | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/datetime/arithmetic.ha b/datetime/arithmetic.ha @@ -19,6 +19,22 @@ export type period = struct { nanoseconds: int, }; +// 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: {}\n", + p.eras, p.years, p.months, p.weeks, p.days, p.hours, + p.minutes, p.seconds, p.nanoseconds + )!; +}; + // Specifies behaviour during calendar arithmetic export type calculus = enum int { LOGICAL,