Skip to content

Commit

Permalink
update tz database (as a git submodule)
Browse files Browse the repository at this point in the history
  • Loading branch information
djzin committed Nov 5, 2016
1 parent 3ee207d commit d2eda9c
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 15,465 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tz"]
path = tz
url = https://github.com/eggert/tz
21 changes: 17 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,29 @@ fn write_directory_file(directory_file: &mut File, table: &Table) {

fn main() {
let mut table = TableBuilder::new();
let tzdir = Path::new("tzdb");
let lines = std::fs::read_dir(tzdir).unwrap().into_iter()
.map(Result::unwrap)
.map(|direntry| direntry.path())

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

let lines = tzfiles.iter()
.map(Path::new)
.map(File::open)
.map(Result::unwrap)
.map(BufReader::new)
.flat_map(BufRead::lines)
.map(Result::unwrap)
.map(strip_comments);

for line in lines {
match Line::from_str(&line).unwrap() {
Line::Zone(zone) => table.add_zone_line(zone).unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions tests/numberphile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ fn libya_2013() {

#[test]
fn israel_palestine() {
let from = Jerusalem.ymd(2016, 10, 22).and_hms(12, 0, 0);
let to = Gaza.ymd(2016, 10, 22).and_hms(12, 0, 0);
let from = Jerusalem.ymd(2016, 10, 29).and_hms(12, 0, 0);
let to = Gaza.ymd(2016, 10, 29).and_hms(12, 0, 0);
assert_eq!(seconds(from, to), 60 * 60);
}

Expand Down
1 change: 1 addition & 0 deletions tz
Submodule tz added at 55ac4f
Loading

0 comments on commit d2eda9c

Please sign in to comment.