Skip to content

Commit 47221e9

Browse files
committed
Use time crate directly to get the year
1 parent 69ffd99 commit 47221e9

File tree

5 files changed

+8
-18
lines changed

5 files changed

+8
-18
lines changed

Cargo.lock

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ name = "cargo"
1717
path = "src/cargo/lib.rs"
1818

1919
[dependencies]
20-
chrono = "0.2.25"
2120
crates-io = { path = "src/crates-io", version = "0.7" }
2221
crossbeam = "0.2"
2322
curl = "0.4.6"
@@ -44,6 +43,7 @@ shell-escape = "0.1"
4443
tar = { version = "0.4", default-features = false }
4544
tempdir = "0.3"
4645
term = "0.4.4"
46+
time = "0.1.36"
4747
toml = "0.3"
4848
url = "1.1"
4949

src/cargo/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#[macro_use] extern crate log;
66
#[macro_use] extern crate serde_derive;
77
#[macro_use] extern crate serde_json;
8-
extern crate chrono;
98
extern crate crates_io as registry;
109
extern crate crossbeam;
1110
extern crate curl;
@@ -27,6 +26,7 @@ extern crate shell_escape;
2726
extern crate tar;
2827
extern crate tempdir;
2928
extern crate term;
29+
extern crate time;
3030
extern crate toml;
3131
extern crate url;
3232

src/cargo/ops/cargo_new.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use git2::Config as GitConfig;
88

99
use term::color::BLACK;
1010

11-
use chrono::{Datelike,Local};
1211
use handlebars::{Handlebars, no_escape};
1312
use tempdir::TempDir;
13+
use time;
1414
use toml;
1515

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

526526
let template_set = try!(get_input_template(config, opts));
527527
for template in template_set.template_files.iter() {

tests/new.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
extern crate cargo;
22
extern crate cargotest;
3-
extern crate chrono;
43
extern crate hamcrest;
54
extern crate tempdir;
5+
extern crate time;
66

77
use std::fs::{self, File};
88
use std::io::prelude::*;
@@ -11,7 +11,6 @@ use std::env;
1111
use cargo::util::ProcessBuilder;
1212
use cargotest::process;
1313
use cargotest::support::{execs, git, paths};
14-
use chrono::{Datelike,Local};
1514
use hamcrest::{assert_that, existing_file, existing_dir, is_not};
1615
use tempdir::TempDir;
1716

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

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

0 commit comments

Comments
 (0)