commit bdea37fbb8654ba2c1ecbf4ae28d0715334796a1
parent c27efbb78bb9f42277ca37eacf7d1166308b1a4d
Author: Byron Torres <b@torresjrjr.com>
Date: Mon, 16 May 2022 17:23:39 +0100
time::chrono: make parse_tzif() accept tz pointer
Signed-off-by: Byron Torres <b@torresjrjr.com>
Diffstat:
2 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/time/chrono/timezone.ha b/time/chrono/timezone.ha
@@ -190,17 +190,8 @@ export const LOCAL: locality = &TZ_local;
static let buf: [os::BUFSIZ]u8 = [0...];
const file = bufio::buffered(file, buf, []);
- TZ_local = match (parse_tzif(&file, timezone {
- name = "Local time",
- timescale = &utc,
- daylength = EARTH_DAY,
- ...
- })) {
- case let tz: timezone =>
- yield tz;
- case =>
- return;
- };
+
+ match (parse_tzif(&file, &TZ_local)) { case => void; };
};
};
diff --git a/time/chrono/tzdb.ha b/time/chrono/tzdb.ha
@@ -41,13 +41,15 @@ export fn tz(name: str) (timezone | fs::error | io::error | invalidtzif) = {
static let buf: [os::BUFSIZ]u8 = [0...];
const bufstrm = bufio::buffered(file, buf, []);
- match (parse_tzif(&bufstrm, timezone {
+
+ let tz = timezone {
name = name,
timescale = &utc,
daylength = EARTH_DAY,
...
- })) {
- case let tz: timezone =>
+ };
+ match (parse_tzif(&bufstrm, &tz)) {
+ case void =>
io::close(&bufstrm)?;
io::close(file)?;
return tz;
@@ -66,10 +68,7 @@ export fn tz(name: str) (timezone | fs::error | io::error | invalidtzif) = {
// fields "zones", "transitions", and "posix_extend" of the given [[timezone]].
//
// See: https://datatracker.ietf.org/doc/html/rfc8536
-fn parse_tzif(
- h: io::handle,
- tz: timezone, // TODO: Make tz a pointer.
-) (timezone | invalidtzif | io::error) = {
+fn parse_tzif(h: io::handle, tz: *timezone) (void | invalidtzif | io::error) = {
const buf1: [1]u8 = [0...];
const buf4: [4]u8 = [0...];
const buf8: [8]u8 = [0...];
@@ -273,7 +272,6 @@ fn parse_tzif(
tz.zones = zones;
tz.transitions = transitions;
tz.posix_extend = posix_extend;
- return tz;
};
fn mustread(h: io::handle, buf: []u8) (void | invalidtzif | io::error) = {