Skip to content

Commit

Permalink
Move tzdata-2017c.tar.gz to the repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Guillemard committed Aug 1, 2019
1 parent b4191b3 commit 99f2d23
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Binary file added external/time/tzdata-2017c.tar.gz
Binary file not shown.
1 change: 0 additions & 1 deletion time/build-script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ authors = ["Thomas Guillemard <me@thog.eu>"]
edition = "2018"

[dependencies]
reqwest = "0.9.17"
tar = "0.4"
flate2 = "1.0"
15 changes: 8 additions & 7 deletions time/build-script/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ fn main() -> Result<(), Box<std::error::Error>> {
let mut option = OpenOptions::new();
option.write(true).read(true).create(true);

for env in env::vars() {
println!("{:?}", env);
}

// NOTE: this point to the sunrise-time crate directory.
let crate_directory = env::var("CARGO_MANIFEST_DIR").unwrap();

let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("timezone_data.rs");
let tz_data_path = Path::new(&out_dir).join("tzcode-latest.tar.gz");
let tz_data_path = Path::new(&crate_directory).parent().unwrap().join("external/time/tzdata-2017c.tar.gz");

let mut tz_data_file = option.open(tz_data_path).unwrap();
let mut dest_file = File::create(&dest_path).unwrap();

let mut res = reqwest::get("https://thog.eu/sunrise/tzdata-2017c.tar.gz")?;

// copy the response body directly to stdout
std::io::copy(&mut res, &mut tz_data_file)?;
tz_data_file.seek(SeekFrom::Start(0)).unwrap();

let tar = GzDecoder::new(tz_data_file);
let mut archive = Archive::new(tar);

Expand Down

0 comments on commit 99f2d23

Please sign in to comment.