From 4e2acb9682f79316e6a9f38eb28b12803767d38e Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Tue, 11 Aug 2020 18:26:40 +0200 Subject: [PATCH] Remove crate time What the crate `time' did was simple enough to rewrite it easily --- Cargo.lock | 53 +------------------------------------------- Cargo.toml | 1 - README.org | 4 ++-- src/battery_state.rs | 11 ++++----- 4 files changed, 7 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 81cd68f..1a9cddc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ checksum = "c74d84029116787153e02106bf53e66828452a4b325cc8652b788b5967c0a0b6" dependencies = [ "num-integer", "num-traits", - "time 0.1.43", + "time", ] [[package]] @@ -382,12 +382,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" - [[package]] name = "proc-macro2" version = "1.0.19" @@ -404,7 +398,6 @@ dependencies = [ "battery", "clap", "notify-rust", - "time 0.2.16", ] [[package]] @@ -451,15 +444,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "standback" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0437cfb83762844799a60e1e3b489d5ceb6a650fbacb86437badc1b6d87b246" -dependencies = [ - "version_check", -] - [[package]] name = "strum" version = "0.8.0" @@ -537,41 +521,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "time" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a51cadc5b1eec673a685ff7c33192ff7b7603d0b75446fb354939ee615acb15" -dependencies = [ - "cfg-if", - "standback", - "time-macros", - "version_check", -] - -[[package]] -name = "time-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ae9b6e9f095bc105e183e3cd493d72579be3181ad4004fceb01adbe9eecab2d" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - -[[package]] -name = "time-macros-impl" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote 1.0.7", - "standback", - "syn 1.0.38", -] - [[package]] name = "typenum" version = "1.12.0" diff --git a/Cargo.toml b/Cargo.toml index e8a4948..a9d5db0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,4 +14,3 @@ publish = false battery = { version = "0.7.5", default-features = false } notify-rust = { version = "4", default-features = false } clap = { version = "3.0.0-beta.1", default-features = false, features = ["std", "derive"] } -time = { version = "0.2", default-features = false } diff --git a/README.org b/README.org index 0e92af1..a103728 100644 --- a/README.org +++ b/README.org @@ -14,8 +14,8 @@ ** Built with [[http://spacemacs.org][file:https://cdn.rawgit.com/syl20bnr/spacemacs/442d025779da2f62fc86c2082703697714db6514/assets/spacemacs-badge.svg]] - PumoPM is written in pure, stable Rust (at least >= 1.45.2). Its four - dependencies are the crates [[https://github.com/svartalf/rust-battery][battery]], [[https://clap.rs/][clap]], [[https://crates.io/crates/time][time]], and [[https://github.com/hoodie/notify-rust][notify-rust]]. + PumoPM is written in pure, stable Rust (at least >= 1.45.2). Its three + dependencies are the crates [[https://github.com/svartalf/rust-battery][battery]], [[https://clap.rs/][clap]], and [[https://github.com/hoodie/notify-rust][notify-rust]]. ** What does Pumo mean? It’s my cat’s name. diff --git a/src/battery_state.rs b/src/battery_state.rs index b836531..b8a468d 100644 --- a/src/battery_state.rs +++ b/src/battery_state.rs @@ -129,13 +129,10 @@ impl BatteryState { match time { Some(e) => { let time = e.value as u64; - let time = time::Time::try_from_hms( - (time / 3600) as u8, - ((time % 3600) / 60) as u8, - (time % 60) as u8, - ) - .unwrap(); - time.to_string() + let hours = time / 3600; + let minutes = (time % 3600) / 60; + let seconds = time % 60; + format!("{:01}:{:02}:{:02}", hours, minutes, seconds) } None => { eprintln!("Couldn’t read remaining time");