Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a86e930f9 | ||
|
|
e2c0b08c03 | ||
|
|
51a200d1a3 |
4 changed files with 37 additions and 12 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -384,7 +384,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time-track"
|
name = "time-track"
|
||||||
version = "2.1.3"
|
version = "2.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "time-track"
|
name = "time-track"
|
||||||
version = "2.1.3"
|
version = "2.1.4"
|
||||||
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
|
||||||
|
|
|
||||||
22
README.md
Normal file
22
README.md
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# time-track
|
||||||
|
|
||||||
|
A simple CLI tool for tracking how much time you have left to work. I find myself stressing about whether I'm hitting 8 real hours, so this little tool helps me avoid wasting
|
||||||
|
time calculating when my work day will end.
|
||||||
|
|
||||||
|
Simply enter times, one per line and send an EOF character when you're done. The first lines opens a span of work and the next line closes it so that you can build up working
|
||||||
|
time be clocking in and out. Finally, you can send additional arguments to the program to configure how long you intend to work (the default is 8 hours).
|
||||||
|
|
||||||
|
```
|
||||||
|
❯ time-track
|
||||||
|
Working for 8 hours
|
||||||
|
Input times one per line. Send an EOF character to finish inputting...
|
||||||
|
8:30
|
||||||
|
9:30
|
||||||
|
11:15
|
||||||
|
12:30
|
||||||
|
13:16
|
||||||
|
18:20
|
||||||
|
19:30
|
||||||
|
20:11 # Send an EOF
|
||||||
|
Exactly done
|
||||||
|
```
|
||||||
23
src/time.rs
23
src/time.rs
|
|
@ -70,17 +70,20 @@ pub fn get_charaterized_time_remaining(
|
||||||
} else {
|
} else {
|
||||||
let diff = target_minutes - total_minutes;
|
let diff = target_minutes - total_minutes;
|
||||||
let (hours, minutes) = to_hrs_minutes(diff);
|
let (hours, minutes) = to_hrs_minutes(diff);
|
||||||
let end_at = (ended_at + Duration::minutes(diff)).time();
|
let now = Local::now();
|
||||||
let end_str = end_at.format("%-I:%M %p");
|
return if ended_at > now {
|
||||||
return if ended_at > Local::now() {
|
let end_at = (ended_at + Duration::minutes(diff)).time();
|
||||||
format!(
|
let end_str = end_at.format("%-I:%M %p");
|
||||||
"You have {} remaining (end at {} starting from {})",
|
format!(
|
||||||
show_time(hours, minutes),
|
"You have {} remaining (end at {} starting from {})",
|
||||||
end_str,
|
show_time(hours, minutes),
|
||||||
ended_at.format("%-I:%M %p"),
|
end_str,
|
||||||
)
|
ended_at.format("%-I:%M %p"),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
format!("You have {} remaining (end at {} starting now)", show_time(hours, minutes), end_str)
|
let end_at = (now + Duration::minutes(diff)).time();
|
||||||
|
let end_str = end_at.format("%-I:%M %p");
|
||||||
|
format!("You have {} remaining (end at {} starting now)", show_time(hours, minutes), end_str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue