Module zoneinfo_parse::line
[−]
[src]
Parsing zoneinfo data files, line-by-line.
This module provides functions that take a line of input from a zoneinfo
data file and attempts to parse it, returning the details of the line if
it gets parsed successfully. It classifies them as Rule
, Link
,
Zone
, or Continuation
lines.
Line
is the type that parses and holds zoneinfo line data. To try to
parse a string, use the Line::from_str
constructor. (This isn’t the
FromStr
trait, so you can’t use parse
on a string. Sorry!)
Examples
Parsing a Rule
line:
use zoneinfo_parse::line::*; use datetime::{Month, Weekday}; use datetime::zone::TimeType; let line = Line::from_str("Rule EU 1977 1980 - Apr Sun>=1 1:00u 1:00 S"); assert_eq!(line, Ok(Line::Rule(Rule { name: "EU", from_year: YearSpec::Number(1977), to_year: Some(YearSpec::Number(1980)), month: MonthSpec(Month::April), day: DaySpec::FirstOnOrAfter(WeekdaySpec(Weekday::Sunday), 1), time: TimeSpec::HoursMinutes(1, 0).with_type(TimeType::UTC), time_to_add: TimeSpec::HoursMinutes(1, 0), letters: Some("S"), })));
Parsing a Zone
line:
use zoneinfo_parse::line::*; use datetime::{Month, Weekday}; use datetime::zone::TimeType; let line = Line::from_str("Zone Australia/Adelaide 9:30 Aus AC%sT 1971 Oct 31 2:00:00"); assert_eq!(line, Ok(Line::Zone(Zone { name: "Australia/Adelaide", info: ZoneInfo { utc_offset: TimeSpec::HoursMinutes(9, 30), saving: Saving::Multiple("Aus"), format: "AC%sT", time: Some(ChangeTime::UntilTime( YearSpec::Number(1971), MonthSpec(Month::October), DaySpec::Ordinal(31), TimeSpec::HoursMinutesSeconds(2, 0, 0).with_type(TimeType::Wall)) ), }, })));
Parsing a Link
line:
use zoneinfo_parse::line::*; let line = Line::from_str("Link Europe/Istanbul Asia/Istanbul"); assert_eq!(line, Ok(Line::Link(Link { existing: "Europe/Istanbul", new: "Asia/Istanbul", })));
Structs
Link |
A link definition line. |
MonthSpec |
A month field, which is actually just a wrapper around
|
Rule |
A rule definition line. |
TimeSpecAndType |
A time spec and a time type. Certain fields need to have both. |
WeekdaySpec |
A weekday field, which is actually just a wrapper around
|
Zone |
A zone definition line. |
ZoneInfo |
The information contained in both zone lines and zone continuation lines. |
Enums
ChangeTime |
The time at which the rules change for a location. |
DaySpec |
A day definition field. |
Error |
An error that can occur during parsing. |
Line |
A type of valid line that has been parsed. |
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. |
TimeSpec |
A time definition field. |
YearSpec |
A year definition field. |