Module parse_zoneinfo::table
source · Expand description
Collecting parsed zoneinfo data lines into a set of time zone data.
This module provides the Table
struct, which is able to take parsed
lines of input from the line
module and coalesce them into a single
set of data.
It’s not as simple as it seems, because the zoneinfo data lines refer to each other through strings: lines of the form “link zone A to B” could be parsed successfully but still fail to be interpreted successfully if “B” doesn’t exist. So it has to check every step of the way—nothing wrong with this, it’s just a consequence of reading data from a text file.
This module only deals with constructing a table from data: any analysis of the data is done elsewhere.
§Example
use parse_zoneinfo::line::{Zone, Line, LineParser, Link};
use parse_zoneinfo::table::{TableBuilder};
let parser = LineParser::default();
let mut builder = TableBuilder::new();
let zone = "Zone Pacific/Auckland 11:39:04 - LMT 1868 Nov 2";
let link = "Link Pacific/Auckland Antarctica/McMurdo";
for line in [zone, link] {
match parser.parse_str(&line)? {
Line::Zone(zone) => builder.add_zone_line(zone).unwrap(),
Line::Continuation(cont) => builder.add_continuation_line(cont).unwrap(),
Line::Rule(rule) => builder.add_rule_line(rule).unwrap(),
Line::Link(link) => builder.add_link_line(link).unwrap(),
Line::Space => {}
}
}
let table = builder.build();
assert!(table.get_zoneset("Pacific/Auckland").is_some());
assert!(table.get_zoneset("Antarctica/McMurdo").is_some());
assert!(table.get_zoneset("UTC").is_none());
Structs§
- An owned rule definition line.
- A table of all the data in one or more zoneinfo files.
- A builder for
Table
values based on various line definitions. - An owned zone definition line.
Enums§
- Something that can go wrong while constructing a
Table
. - The format string to generate a time zone abbreviation from.
- The amount of daylight saving time (DST) to apply to this timespan. This is a special type for a certain field in a zone line, which can hold different types of value.