This patch removes the dependency on tzdata when running the tests.
---
The proper way would be to only compile the zone on +test, but I do not
want to fiddle with the build system right now, since there are ongoing
discussions on how to replace it.
scripts/gen-stdlib | 6 +-
stdlib.mk | 12 +-
time/date/date.ha | 3 +-
time/date/reckon.ha | 3 +-
time/date/sampletz.ha | 801 ++++++++++++++++++++++++++++++++++++++++++
5 files changed, 815 insertions(+), 10 deletions(-)
create mode 100644 time/date/sampletz.ha
diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib
index cfb51097..c7ef6955 100755
--- a/scripts/gen-stdlib
+++ b/scripts/gen-stdlib
@@ -1406,7 +1406,8 @@ time_date() {
period.ha \
reckon.ha \
tarithm.ha \
- virtual.ha
+ virtual.ha \
+ sampletz.ha
gen_ssa -plinux time::date \
ascii errors fmt io strconv strings strio time time::chrono
gen_srcs -pfreebsd time::date \
@@ -1422,7 +1423,8 @@ time_date() {
period.ha \
reckon.ha \
tarithm.ha \
- virtual.ha
+ virtual.ha \
+ sampletz.ha
gen_ssa -pfreebsd time::date \
ascii errors fmt io strconv strings strio time time::chrono
}
diff --git a/stdlib.mk b/stdlib.mk
index db858e39..f59ba137 100644
--- a/stdlib.mk
+++ b/stdlib.mk
@@ -2182,7 +2182,8 @@ stdlib_time_date_linux_srcs = \
$(STDLIB)/time/date/period.ha \
$(STDLIB)/time/date/reckon.ha \
$(STDLIB)/time/date/tarithm.ha \
- $(STDLIB)/time/date/virtual.ha
+ $(STDLIB)/time/date/virtual.ha \
+ $(STDLIB)/time/date/sampletz.ha
$(HARECACHE)/time/date/time_date-linux.ssa: $(stdlib_time_date_linux_srcs) $(stdlib_rt) $(stdlib_ascii_$(PLATFORM)) $(stdlib_errors_$(PLATFORM)) $(stdlib_fmt_$(PLATFORM)) $(stdlib_io_$(PLATFORM)) $(stdlib_strconv_$(PLATFORM)) $(stdlib_strings_$(PLATFORM)) $(stdlib_strio_$(PLATFORM)) $(stdlib_time_$(PLATFORM)) $(stdlib_time_chrono_$(PLATFORM))
@printf 'HAREC \t$@\n'
@@ -2204,7 +2205,8 @@ stdlib_time_date_freebsd_srcs = \
$(STDLIB)/time/date/period.ha \
$(STDLIB)/time/date/reckon.ha \
$(STDLIB)/time/date/tarithm.ha \
- $(STDLIB)/time/date/virtual.ha
+ $(STDLIB)/time/date/virtual.ha \
+ $(STDLIB)/time/date/sampletz.ha
$(HARECACHE)/time/date/time_date-freebsd.ssa: $(stdlib_time_date_freebsd_srcs) $(stdlib_rt) $(stdlib_ascii_$(PLATFORM)) $(stdlib_errors_$(PLATFORM)) $(stdlib_fmt_$(PLATFORM)) $(stdlib_io_$(PLATFORM)) $(stdlib_strconv_$(PLATFORM)) $(stdlib_strings_$(PLATFORM)) $(stdlib_strio_$(PLATFORM)) $(stdlib_time_$(PLATFORM)) $(stdlib_time_chrono_$(PLATFORM))
@printf 'HAREC \t$@\n'
@@ -4654,7 +4656,8 @@ testlib_time_date_linux_srcs = \
$(STDLIB)/time/date/period.ha \
$(STDLIB)/time/date/reckon.ha \
$(STDLIB)/time/date/tarithm.ha \
- $(STDLIB)/time/date/virtual.ha
+ $(STDLIB)/time/date/virtual.ha \
+ $(STDLIB)/time/date/sampletz.ha
$(TESTCACHE)/time/date/time_date-linux.ssa: $(testlib_time_date_linux_srcs) $(testlib_rt) $(testlib_ascii_$(PLATFORM)) $(testlib_errors_$(PLATFORM)) $(testlib_fmt_$(PLATFORM)) $(testlib_io_$(PLATFORM)) $(testlib_strconv_$(PLATFORM)) $(testlib_strings_$(PLATFORM)) $(testlib_strio_$(PLATFORM)) $(testlib_time_$(PLATFORM)) $(testlib_time_chrono_$(PLATFORM))
@printf 'HAREC \t$@\n'
@@ -4676,7 +4679,8 @@ testlib_time_date_freebsd_srcs = \
$(STDLIB)/time/date/period.ha \
$(STDLIB)/time/date/reckon.ha \
$(STDLIB)/time/date/tarithm.ha \
- $(STDLIB)/time/date/virtual.ha
+ $(STDLIB)/time/date/virtual.ha \
+ $(STDLIB)/time/date/sampletz.ha
$(TESTCACHE)/time/date/time_date-freebsd.ssa: $(testlib_time_date_freebsd_srcs) $(testlib_rt) $(testlib_ascii_$(PLATFORM)) $(testlib_errors_$(PLATFORM)) $(testlib_fmt_$(PLATFORM)) $(testlib_io_$(PLATFORM)) $(testlib_strconv_$(PLATFORM)) $(testlib_strings_$(PLATFORM)) $(testlib_strio_$(PLATFORM)) $(testlib_time_$(PLATFORM)) $(testlib_time_chrono_$(PLATFORM))
@printf 'HAREC \t$@\n'
diff --git a/time/date/date.ha b/time/date/date.ha
index de8e7521..74e91ae3 100644
--- a/time/date/date.ha
+++ b/time/date/date.ha
@@ -234,8 +234,7 @@ export fn from_str(
};
@test fn from_str() void = {
- const amst = chrono::tz("Europe/Amsterdam")!;
- defer chrono::timezone_free(amst);
+ const amst = &zone_amsterdam;
let testcases: [_](str, str, []chrono::locality, (date | error)) = [
(STAMP_NOZL, "2001-02-03 15:16:17.123456789 +0000 UTC UTC", [],
diff --git a/time/date/reckon.ha b/time/date/reckon.ha
index c114c026..8b60208c 100644
--- a/time/date/reckon.ha
+++ b/time/date/reckon.ha
@@ -266,8 +266,7 @@ 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);
+ const Amst = &zone_amsterdam;
// no-op period, calculus::CEIL
diff --git a/time/date/sampletz.ha b/time/date/sampletz.ha
new file mode 100644
index 00000000..54c7cd5b
--- /dev/null
+++ b/time/date/sampletz.ha
@@ -0,0 +1,801 @@
+use time::chrono::*;
+use time;
+
+const zone_amsterdam = timezone {
+ name = "Europe/Amsterdam",
+ timescale = &utc,
+ daylength = 24 * time::HOUR,
+ posix_extend = "CET-1CEST,M3.5.0,M10.5.0/3",
+ zones = [
+ zone { zoff = 1050000000000, abbr = "LMT", dst = false, ... },
+ zone { zoff = 1050000000000, abbr = "BMT", dst = false, ... },
+ zone { zoff = 0, abbr = "WET", dst = false, ... },
+ zone { zoff = 3600000000000, abbr = "CET", dst = false, ... },
+ zone { zoff = 7200000000000, abbr = "CEST", dst = true, ... },
+ zone { zoff = 3600000000000, abbr = "CET", dst = false, ... },
+ zone { zoff = 7200000000000, abbr = "CEST", dst = true, ... },
+ zone { zoff = 3600000000000, abbr = "WEST", dst = true, ... },
+ zone { zoff = 0, abbr = "WET", dst = false, ... },
+ zone { zoff = 0, abbr = "WET", dst = false, ... },
+ zone { zoff = 7200000000000, abbr = "CEST", dst = true, ... },
+ zone { zoff = 3600000000000, abbr = "CET", dst = false, ... },
+ ],
+ transitions = [
+ transition {
+ when = time::instant { sec = -2840141850, nsec = 0 },
+ zoneindex = 1
+ },
+ transition {
+ when = time::instant { sec = -2450995200, nsec = 0 },
+ zoneindex = 2
+ },
+ transition {
+ when = time::instant { sec = -1740355200, nsec = 0 },
+ zoneindex = 3
+ },
+ transition {
+ when = time::instant { sec = -1693702800, nsec = 0 },
+ zoneindex = 6
+ },
+ transition {
+ when = time::instant { sec = -1680483600, nsec = 0 },
+ zoneindex = 3
+ },
+ transition {
+ when = time::instant { sec = -1663455600, nsec = 0 },
+ zoneindex = 4
+ },
+ transition {
+ when = time::instant { sec = -1650150000, nsec = 0 },
+ zoneindex = 5
+ },
+ transition {
+ when = time::instant { sec = -1632006000, nsec = 0 },
+ zoneindex = 4
+ },
+ transition {
+ when = time::instant { sec = -1618700400, nsec = 0 },
+ zoneindex = 5
+ },
+ transition {
+ when = time::instant { sec = -1613826000, nsec = 0 },
+ zoneindex = 9
+ },
+ transition {
+ when = time::instant { sec = -1604278800, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1585530000, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1574038800, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1552266000, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1539997200, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1520557200, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1507510800, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1490576400, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1473642000, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1459126800, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1444006800, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1427677200, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1411952400, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1396227600, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1379293200, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1364778000, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1348448400, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1333328400, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1316394000, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1301263200, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1284328800, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1269813600, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1253484000, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1238364000, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1221429600, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1206914400, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1191189600, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1175464800, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1160344800, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1143410400, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1127685600, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1111960800, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1096840800, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1080511200, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1063576800, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1049061600, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1033336800, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -1017612000, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -1002492000, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -986162400, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -969228000, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -950479200, nsec = 0 },
+ zoneindex = 8
+ },
+ transition {
+ when = time::instant { sec = -942012000, nsec = 0 },
+ zoneindex = 7
+ },
+ transition {
+ when = time::instant { sec = -934668000, nsec = 0 },
+ zoneindex = 4
+ },
+ transition {
+ when = time::instant { sec = -857257200, nsec = 0 },
+ zoneindex = 5
+ },
+ transition {
+ when = time::instant { sec = -844556400, nsec = 0 },
+ zoneindex = 4
+ },
+ transition {
+ when = time::instant { sec = -828226800, nsec = 0 },
+ zoneindex = 5
+ },
+ transition {
+ when = time::instant { sec = -812502000, nsec = 0 },
+ zoneindex = 4
+ },
+ transition {
+ when = time::instant { sec = -798073200, nsec = 0 },
+ zoneindex = 5
+ },
+ transition {
+ when = time::instant { sec = -781052400, nsec = 0 },
+ zoneindex = 4
+ },
+ transition {
+ when = time::instant { sec = -766623600, nsec = 0 },
+ zoneindex = 5
+ },
+ transition {
+ when = time::instant { sec = -745455600, nsec = 0 },
+ zoneindex = 4
+ },
+ transition {
+ when = time::instant { sec = -733273200, nsec = 0 },
+ zoneindex = 5
+ },
+ transition {
+ when = time::instant { sec = 228877200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 243997200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 260326800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 276051600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 291776400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 307501200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 323830800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 338950800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 354675600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 370400400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 386125200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 401850000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 417574800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 433299600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 449024400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 465354000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 481078800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 496803600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 512528400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 528253200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 543978000, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 559702800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 575427600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 591152400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 606877200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 622602000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 638326800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 654656400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 670381200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 686106000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 701830800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 717555600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 733280400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 749005200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 764730000, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 780454800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 796179600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 811904400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 828234000, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 846378000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 859683600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 877827600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 891133200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 909277200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 922582800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 941331600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 954032400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 972781200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 985482000, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1004230800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1017536400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1035680400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1048986000, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1067130000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1080435600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1099184400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1111885200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1130634000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1143334800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1162083600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1174784400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1193533200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1206838800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1224982800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1238288400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1256432400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1269738000, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1288486800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1301187600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1319936400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1332637200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1351386000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1364691600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1382835600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1396141200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1414285200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1427590800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1445734800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1459040400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1477789200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1490490000, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1509238800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1521939600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1540688400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1553994000, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1572138000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1585443600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1603587600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1616893200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1635642000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1648342800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1667091600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1679792400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1698541200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1711846800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1729990800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1743296400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1761440400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1774746000, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1792890000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1806195600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1824944400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1837645200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1856394000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1869094800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1887843600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1901149200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1919293200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1932598800, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1950742800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1964048400, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 1982797200, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 1995498000, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 2014246800, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 2026947600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 2045696400, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 2058397200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 2077146000, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 2090451600, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 2108595600, nsec = 0 },
+ zoneindex = 11
+ },
+ transition {
+ when = time::instant { sec = 2121901200, nsec = 0 },
+ zoneindex = 10
+ },
+ transition {
+ when = time::instant { sec = 2140045200, nsec = 0 },
+ zoneindex = 11
+ },
+ ],
+};
+
+@test fn tz() void = {
+ let am = match (tz("Europe/Amsterdam")) {
+ case let l: locality =>
+ yield l;
+ case =>
+ return;
+ };
+ defer timezone_free(am);
+
+ let z = &zone_amsterdam;
+
+ assert(am.timescale == z.timescale);
+ assert(am.daylength == z.daylength);
+
+ assert(len(am.zones) == len(z.zones));
+ for (let i = 0z; i < len(am.zones); i += 1) {
+ let ez = am.zones[i];
+ let az = z.zones[i];
+ assert(ez.zoff == az.zoff);
+ assert(ez.name == az.name);
+ assert(ez.abbr == az.abbr);
+ assert(ez.dst == az.dst);
+ };
+
+ assert(len(am.transitions) == len(z.transitions));
+ for (let i = 0z; i < len(am.transitions); i += 1) {
+ let et = am.transitions[i];
+ let at = z.transitions[i];
+ assert(et.when.sec == at.when.sec);
+ assert(et.when.nsec == at.when.nsec);
+ assert(et.zoneindex == at.zoneindex);
+ };
+
+ assert(am.posix_extend == z.posix_extend);
+};
--
2.41.0