Mercurial > lbo > hg > myi3stat
changeset 38:0227aba85c56
Use time crate for clock metric
It's more reliable for the local time.
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Wed, 23 Mar 2016 21:20:58 +0100 |
parents | c65c28c13591 |
children | f4652b525ec7 |
files | Cargo.lock Cargo.toml src/metrics/time.rs |
diffstat | 3 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/Cargo.lock Thu Feb 18 16:22:09 2016 +0100 +++ b/Cargo.lock Wed Mar 23 21:20:58 2016 +0100 @@ -2,10 +2,11 @@ name = "myi3stat" version = "0.1.0" dependencies = [ - "chrono 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.48 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -18,10 +19,10 @@ [[package]] name = "chrono" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -54,7 +55,7 @@ [[package]] name = "num" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]]
--- a/Cargo.toml Thu Feb 18 16:22:09 2016 +0100 +++ b/Cargo.toml Wed Mar 23 21:20:58 2016 +0100 @@ -6,5 +6,6 @@ [dependencies] getopts = ">=0.2" regex = ">=0.1" +time = ">=0.1.34" chrono = ">=0.2" libc = ">=0.2"
--- a/src/metrics/time.rs Thu Feb 18 16:22:09 2016 +0100 +++ b/src/metrics/time.rs Wed Mar 23 21:20:58 2016 +0100 @@ -2,8 +2,8 @@ use framework::*; -extern crate chrono; -use self::chrono::Local; +extern crate time; +//use self::time; struct TimeMetric { fmt: String, @@ -16,8 +16,8 @@ self.fmt = arg.unwrap_or(String::from(DEFAULT_FMT)); } fn render(&mut self, _: &mut MetricState) -> RenderResult { - let t = Local::now(); - let tstr = format!("{}", t.format(&self.fmt)); + let t = time::now(); + let tstr = format!("{}", t.strftime(&self.fmt).unwrap()); RenderResult::new(tstr, Color::Default) }