diff --git a/Cargo.toml b/Cargo.toml index a796f98a..46d90217 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,6 @@ serde = "0.7" serde_json = "0.7" serde_macros = { version = "0.7", optional = true } tempfile = "~2.1.3" -time = "~0.1.34" url = "~0.5.0" log = "0.3.5" env_logger = "0.3.2" diff --git a/src/lib.rs b/src/lib.rs index c0c5ff30..a5b8a978 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,6 @@ extern crate rpassword; extern crate rustc_serialize; extern crate serde; extern crate serde_json; -extern crate time; extern crate tempfile; extern crate url; diff --git a/src/util/mod.rs b/src/util/mod.rs index 93118714..933e481e 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -4,7 +4,7 @@ use std::io; use std::ops::{Mul, Rem, Shr}; use std::fs; use std::path::Path; -use time; +use std::time::{UNIX_EPOCH, SystemTime}; mod int128; mod spotify_id; @@ -34,8 +34,11 @@ impl IgnoreExt for Result { } pub fn now_ms() -> i64 { - let ts = time::now_utc().to_timespec(); - ts.sec * 1000 + ts.nsec as i64 / 1000000 + let dur = match SystemTime::now().duration_since(UNIX_EPOCH) { + Ok(dur) => dur, + Err(err) => err.duration(), + }; + (dur.as_secs() * 1000 + (dur.subsec_nanos() / 1000_000) as u64) as i64 } pub fn mkdir_existing(path: &Path) -> io::Result<()> {