hare

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

commit 565a111af32cffedb2a62446b9edf24a602614da
parent 0cf443bbfb121fbf04d0d138161b6073a088bef9
Author: Byron Torres <b@torresjrjr.com>
Date:   Fri, 16 Jun 2023 02:20:03 +0100

time::date: avoid tz() in tests, TZDB dependency

Running `make check` would invoke time::chrono::tz(), which relies on an
installation of the Timezone database, complicating matters for distro
package maintainers.

Diffstat:
Mtime/date/date.ha | 9++++-----
Mtime/date/reckon.ha | 5+----
2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/time/date/date.ha b/time/date/date.ha @@ -234,9 +234,6 @@ export fn from_str( }; @test fn from_str() void = { - const amst = chrono::tz("Europe/Amsterdam")!; - defer chrono::timezone_free(amst); - let testcases: [_](str, str, []chrono::locality, (date | error)) = [ (STAMP_NOZL, "2001-02-03 15:16:17.123456789 +0000 UTC UTC", [], new(chrono::UTC, 0, 2001, 2, 3, 15, 16, 17, 123456789)!), @@ -254,8 +251,10 @@ export fn from_str( new(chrono::UTC, 0, 2009, 6, 30, 18, 30)!), ("%FT%T.%N%Z", "2009-06-30T18:30:00.987654321Z", [], new(chrono::UTC, 0, 2009, 6, 30, 18, 30, 0, 987654321)!), - ("%FT%T%z %L", "2009-06-30T18:30:00+0200 Europe/Amsterdam", [amst], - new(amst, 2 * time::HOUR, 2009, 6, 30, 18, 30)!), + // TODO: for the tests overhaul, when internal test timezones + // are available, check for %L + //("%FT%T%z %L", "2009-06-30T18:30:00+0200 Europe/Amsterdam", [amst], + // new(amst, 2 * time::HOUR, 2009, 6, 30, 18, 30)!), ("%Y", "a", [], 'a': parsefail), ("%X", "2008", [], '2': parsefail), diff --git a/time/date/reckon.ha b/time/date/reckon.ha @@ -266,9 +266,6 @@ fn reckon_nanoseconds(r: *virtual, nsecs: i64, calc: calculus) void = { }; @test fn reckon() void = { - const Amst = chrono::tz("Europe/Amsterdam")!; - defer chrono::timezone_free(Amst); - // no-op period, calculus::CEIL let p = period { ... }; @@ -281,7 +278,7 @@ fn reckon_nanoseconds(r: *virtual, nsecs: i64, calc: calculus) void = { let r = reckon(a, 0, p); assert(chrono::eq(&a, &r)!, "02. incorrect result"); - let a = new(Amst, 1 * time::HOUR, 2019, 12, 27, 22, 7, 8, 0)!; + let a = new(chrono::UTC, 0, 1970, 1, 1, 0, 0, 0, 0)!; let r = reckon(a, 0, p); assert(chrono::eq(&a, &r)!, "03. incorrect result");