Add the option to treat minutes and hours flags as discounting from an 8 hr day
This commit is contained in:
parent
27b9345377
commit
7a6aa2489b
4 changed files with 11 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -384,7 +384,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time-track"
|
name = "time-track"
|
||||||
version = "2.0.1"
|
version = "2.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "time-track"
|
name = "time-track"
|
||||||
version = "2.0.1"
|
version = "2.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,8 @@ pub struct Args {
|
||||||
/// How many minutes you intend to work (sums with `hours`)
|
/// How many minutes you intend to work (sums with `hours`)
|
||||||
#[arg(long, default_value_t = 0)]
|
#[arg(long, default_value_t = 0)]
|
||||||
pub minutes: i64,
|
pub minutes: i64,
|
||||||
|
|
||||||
|
/// If true, the the hours and minutes fields are treated as subtracting from 8 hours
|
||||||
|
#[arg(long, default_value_t = false)]
|
||||||
|
pub discount: bool,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,11 @@ fn main() -> Result<()> {
|
||||||
total_minutes += (now - remaining).num_minutes();
|
total_minutes += (now - remaining).num_minutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
let target_minutes = args.hours * 60 + args.minutes;
|
let target_minutes = if args.discount {
|
||||||
|
(8 * 60) - (args.hours * 60 + args.minutes)
|
||||||
|
} else {
|
||||||
|
args.hours * 60 + args.minutes
|
||||||
|
};
|
||||||
println!("{}", time::get_charaterized_time_remaining(total_minutes, target_minutes));
|
println!("{}", time::get_charaterized_time_remaining(total_minutes, target_minutes));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue