Close unpaired spans on CTRL+D in live mode

This commit is contained in:
Campbell Alden 2023-07-26 15:01:12 +09:00
parent 1f532ead7f
commit 7d90764cbd
3 changed files with 8 additions and 3 deletions

2
Cargo.lock generated
View file

@ -354,7 +354,7 @@ dependencies = [
[[package]]
name = "time-track"
version = "0.3.0"
version = "0.3.1"
dependencies = [
"atty",
"chrono",

View file

@ -1,6 +1,6 @@
[package]
name = "time-track"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -71,7 +71,12 @@ fn live_spans() -> Vec<Duration> {
}
}
if let Some(unpaired) = seen {
println!("Ended with an open span from {unpaired}... Ignoring");
println!("Closing unpaired span now");
let mut now = Local::now().naive_local().time();
if now < unpaired {
now = now + Duration::hours(12);
}
durations.push(now - unpaired);
}
return durations;
}