Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse-zoneinfo: replace rule parser with simple state machine #172

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
20 changes: 4 additions & 16 deletions chrono-tz-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,24 +511,12 @@ pub fn main() {

let parser = LineParser::default();
let mut table = TableBuilder::new();

let tzfiles = [
"tz/africa",
"tz/antarctica",
"tz/asia",
"tz/australasia",
"tz/backward",
"tz/etcetera",
"tz/europe",
"tz/northamerica",
"tz/southamerica",
];

let lines = tzfiles
let lines = parse_zoneinfo::FILES
.iter()
.map(Path::new)
.map(|p| {
Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| String::new())).join(p)
Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| String::new()))
.join("tz")
.join(p)
})
.map(|path| {
File::open(&path).unwrap_or_else(|e| panic!("cannot open {}: {}", path.display(), e))
Expand Down
12 changes: 12 additions & 0 deletions parse-zoneinfo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@ pub mod line;
pub mod structure;
pub mod table;
pub mod transitions;

pub const FILES: &[&str] = &[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we want to hardcode this list in parse-zoneinfo.

For my personal experiments the past year I removed backward, included backzone, occasionally included factory, and filtered parts of etcetera.

Maybe move the change out of this PR so we can discuss it separately?

"africa",
"antarctica",
"asia",
"australasia",
"backward",
"etcetera",
"europe",
"northamerica",
"southamerica",
];