Compare commits

..

2 Commits

Author SHA1 Message Date
DuckDuckWhale
29928aa763 Cargo: update dependencies 2020-11-19 07:55:16 -08:00
DuckDuckWhale
b3612b89a3 Fix: displaying 0 time on 3572 seconds
Previously it is only rounded to the nearest minute after calculating
the number of hours, which led to hour calculation showing 0 hour and
minutes rounding to 60 and showing 0 minute as well.  Now it is properly
rounded to the nearest minute before the formatting logic.
2020-11-19 00:37:49 -08:00
2 changed files with 16 additions and 14 deletions

24
Cargo.lock generated
View File

@ -32,9 +32,9 @@ checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.62" version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40" checksum = "ad9c6140b5a2c7db40ea56eb1821245e5362b44385c05b76288b1a599934ac87"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -74,7 +74,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f" checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f"
dependencies = [ dependencies = [
"percent-encoding", "percent-encoding",
"time 0.2.22", "time 0.2.23",
"version_check", "version_check",
] ]
@ -90,7 +90,7 @@ dependencies = [
"publicsuffix", "publicsuffix",
"serde", "serde",
"serde_json", "serde_json",
"time 0.2.22", "time 0.2.23",
"url", "url",
] ]
@ -276,9 +276,9 @@ checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
[[package]] [[package]]
name = "ring" name = "ring"
version = "0.16.15" version = "0.16.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4" checksum = "b72b84d47e8ec5a4f2872e8262b8f8256c5be1c938a7d6d3a867a3ba8f722f74"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -387,9 +387,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]] [[package]]
name = "standback" name = "standback"
version = "0.2.11" version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4e0831040d2cf2bdfd51b844be71885783d489898a192f254ae25d57cce725c" checksum = "cf906c8b8fc3f6ecd1046e01da1d8ddec83e48c8b08b84dcc02b585a6bedf5a8"
dependencies = [ dependencies = [
"version_check", "version_check",
] ]
@ -467,9 +467,9 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.2.22" version = "0.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55b7151c9065e80917fbf285d9a5d1432f60db41d170ccafc749a136b41a93af" checksum = "bcdaeea317915d59b2b4cd3b5efcd156c309108664277793f5351700c02ce98b"
dependencies = [ dependencies = [
"const_fn", "const_fn",
"libc", "libc",
@ -529,9 +529,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-normalization" name = "unicode-normalization"
version = "0.1.14" version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7f98e67a4d84f730d343392f9bfff7d21e3fca562b9cb7a43b768350beeddc6" checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606"
dependencies = [ dependencies = [
"tinyvec", "tinyvec",
] ]

View File

@ -47,6 +47,8 @@ fn main() {
.into_json_deserialize::<Vec<TrackedTime>>() .into_json_deserialize::<Vec<TrackedTime>>()
.expect("Failed to parse response as UTF-8 string."); .expect("Failed to parse response as UTF-8 string.");
let seconds: u64 = times.iter().map(|tracked| tracked.time).sum(); let seconds: u64 = times.iter().map(|tracked| tracked.time).sum();
// round up if more then half a minute is left
let minutes = (seconds + 30) / 60;
let mut map = HashMap::new(); let mut map = HashMap::new();
for tracked in times { for tracked in times {
let (time, _) = map let (time, _) = map
@ -59,8 +61,8 @@ fn main() {
println!( println!(
"You spent {} hours and {} minutes on {} issues in the last 24 hours{}", "You spent {} hours and {} minutes on {} issues in the last 24 hours{}",
seconds / 3600, minutes / 60,
(seconds + 30) / 60 % 60, minutes % 60,
times.len(), times.len(),
if times.is_empty() { '.' } else { ':' } if times.is_empty() { '.' } else { ':' }
); );