Module 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, Link};
use parse_zoneinfo::table::TableBuilder;

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] {
    builder.add_line(Line::new(&line)?).unwrap();
}

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§

RuleInfo
An owned rule definition line.
Table
A table of all the data in one or more zoneinfo files.
TableBuilder
A builder for Table values based on various line definitions.
ZoneInfo
An owned zone definition line.

Enums§

Error
Something that can go wrong while constructing a Table.
Format
The format string to generate a time zone abbreviation from.
Saving
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.