commit 0d7e2acdcf766e740f5f4f794e7221a01f05782e
parent 1a66514c1f3cead781ccdb28091f17263520473a
Author: Byron Torres <b@torresjrjr.com>
Date: Sat, 8 Jan 2022 20:15:11 +0000
time::olsen: new module
Signed-off-by: Byron Torres <b@torresjrjr.com>
Diffstat:
4 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib
@@ -1195,6 +1195,12 @@ time_chrono() {
gen_ssa time::chrono time
}
+time_olsen() {
+ gen_srcs time::olsen \
+ olsen.ha
+ gen_ssa time::olsen time time::chrono datetime
+}
+
types() {
gen_srcs types \
limits.ha \
@@ -1363,6 +1369,7 @@ strio
temp linux freebsd
time linux freebsd
time::chrono
+time::olsen
types
unix linux freebsd
unix::hosts
diff --git a/stdlib.mk b/stdlib.mk
@@ -622,6 +622,12 @@ stdlib_deps_any+=$(stdlib_time_chrono_any)
stdlib_time_chrono_linux=$(stdlib_time_chrono_any)
stdlib_time_chrono_freebsd=$(stdlib_time_chrono_any)
+# gen_lib time::olsen (any)
+stdlib_time_olsen_any=$(HARECACHE)/time/olsen/time_olsen-any.o
+stdlib_deps_any+=$(stdlib_time_olsen_any)
+stdlib_time_olsen_linux=$(stdlib_time_olsen_any)
+stdlib_time_olsen_freebsd=$(stdlib_time_olsen_any)
+
# gen_lib types (any)
stdlib_types_any=$(HARECACHE)/types/types-any.o
stdlib_deps_any+=$(stdlib_types_any)
@@ -1800,6 +1806,16 @@ $(HARECACHE)/time/chrono/time_chrono-any.ssa: $(stdlib_time_chrono_any_srcs) $(s
@HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Ntime::chrono \
-t$(HARECACHE)/time/chrono/time_chrono.td $(stdlib_time_chrono_any_srcs)
+# time::olsen (+any)
+stdlib_time_olsen_any_srcs= \
+ $(STDLIB)/time/olsen/olsen.ha
+
+$(HARECACHE)/time/olsen/time_olsen-any.ssa: $(stdlib_time_olsen_any_srcs) $(stdlib_rt) $(stdlib_time_$(PLATFORM)) $(stdlib_time_chrono_$(PLATFORM)) $(stdlib_datetime_$(PLATFORM))
+ @printf 'HAREC \t$@\n'
+ @mkdir -p $(HARECACHE)/time/olsen
+ @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Ntime::olsen \
+ -t$(HARECACHE)/time/olsen/time_olsen.td $(stdlib_time_olsen_any_srcs)
+
# types (+any)
stdlib_types_any_srcs= \
$(STDLIB)/types/limits.ha \
@@ -2569,6 +2585,12 @@ testlib_deps_any+=$(testlib_time_chrono_any)
testlib_time_chrono_linux=$(testlib_time_chrono_any)
testlib_time_chrono_freebsd=$(testlib_time_chrono_any)
+# gen_lib time::olsen (any)
+testlib_time_olsen_any=$(TESTCACHE)/time/olsen/time_olsen-any.o
+testlib_deps_any+=$(testlib_time_olsen_any)
+testlib_time_olsen_linux=$(testlib_time_olsen_any)
+testlib_time_olsen_freebsd=$(testlib_time_olsen_any)
+
# gen_lib types (any)
testlib_types_any=$(TESTCACHE)/types/types-any.o
testlib_deps_any+=$(testlib_types_any)
@@ -3792,6 +3814,16 @@ $(TESTCACHE)/time/chrono/time_chrono-any.ssa: $(testlib_time_chrono_any_srcs) $(
@HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Ntime::chrono \
-t$(TESTCACHE)/time/chrono/time_chrono.td $(testlib_time_chrono_any_srcs)
+# time::olsen (+any)
+testlib_time_olsen_any_srcs= \
+ $(STDLIB)/time/olsen/olsen.ha
+
+$(TESTCACHE)/time/olsen/time_olsen-any.ssa: $(testlib_time_olsen_any_srcs) $(testlib_rt) $(testlib_time_$(PLATFORM)) $(testlib_time_chrono_$(PLATFORM)) $(testlib_datetime_$(PLATFORM))
+ @printf 'HAREC \t$@\n'
+ @mkdir -p $(TESTCACHE)/time/olsen
+ @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Ntime::olsen \
+ -t$(TESTCACHE)/time/olsen/time_olsen.td $(testlib_time_olsen_any_srcs)
+
# types (+any)
testlib_types_any_srcs= \
$(STDLIB)/types/limits.ha \
diff --git a/time/olsen/README b/time/olsen/README
@@ -0,0 +1,5 @@
+The time::olsen module provides access to the IANA Time Zone Database.
+This module parses the timezone data normally installed on your system.
+The database is also known as zoneinfo, tzdata, or the Olsen database.
+
+See https://www.iana.org/time-zones
diff --git a/time/olsen/olsen.ha b/time/olsen/olsen.ha
@@ -0,0 +1,8 @@
+use time;
+use time::chrono;
+use datetime;
+
+fn tz(id: str) *chrono::timezone = {
+ // TODO: retrieve timezone from system zoneinfo database
+ return chrono::local;
+};