Skip to content

Commit

Permalink
Use time crate directly to get the year
Browse files Browse the repository at this point in the history
  • Loading branch information
jryans committed Mar 6, 2017
1 parent 69ffd99 commit 47221e9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
12 changes: 1 addition & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ name = "cargo"
path = "src/cargo/lib.rs"

[dependencies]
chrono = "0.2.25"
crates-io = { path = "src/crates-io", version = "0.7" }
crossbeam = "0.2"
curl = "0.4.6"
Expand All @@ -44,6 +43,7 @@ shell-escape = "0.1"
tar = { version = "0.4", default-features = false }
tempdir = "0.3"
term = "0.4.4"
time = "0.1.36"
toml = "0.3"
url = "1.1"

Expand Down
2 changes: 1 addition & 1 deletion src/cargo/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#[macro_use] extern crate log;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate serde_json;
extern crate chrono;
extern crate crates_io as registry;
extern crate crossbeam;
extern crate curl;
Expand All @@ -27,6 +26,7 @@ extern crate shell_escape;
extern crate tar;
extern crate tempdir;
extern crate term;
extern crate time;
extern crate toml;
extern crate url;

Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use git2::Config as GitConfig;

use term::color::BLACK;

use chrono::{Datelike,Local};
use handlebars::{Handlebars, no_escape};
use tempdir::TempDir;
use time;
use toml;

use core::Workspace;
Expand Down Expand Up @@ -521,7 +521,7 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
let mut data = BTreeMap::new();
data.insert("name".to_owned(), name.to_owned());
data.insert("author".to_owned(), author);
data.insert("year".to_owned(), Local::now().year().to_string());
data.insert("year".to_owned(), (time::now().tm_year + 1900).to_string());

let template_set = try!(get_input_template(config, opts));
for template in template_set.template_files.iter() {
Expand Down
6 changes: 3 additions & 3 deletions tests/new.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern crate cargo;
extern crate cargotest;
extern crate chrono;
extern crate hamcrest;
extern crate tempdir;
extern crate time;

use std::fs::{self, File};
use std::io::prelude::*;
Expand All @@ -11,7 +11,6 @@ use std::env;
use cargo::util::ProcessBuilder;
use cargotest::process;
use cargotest::support::{execs, git, paths};
use chrono::{Datelike,Local};
use hamcrest::{assert_that, existing_file, existing_dir, is_not};
use tempdir::TempDir;

Expand Down Expand Up @@ -95,7 +94,8 @@ fn main () {
let license = paths::root().join("foo/LICENSE");
let mut contents = String::new();
File::open(&license).unwrap().read_to_string(&mut contents).unwrap();
assert!(contents.contains(&format!("(c) {} {}", Local::now().year(), "foo")));
let expected = format!("(c) {} {}", (time::now().tm_year + 1900).to_string(), "foo");
assert!(contents.contains(&expected));

assert_that(cargo_process("build").cwd(&paths::root().join("foo")),
execs().with_status(0));
Expand Down

0 comments on commit 47221e9

Please sign in to comment.