tracked time total

This commit is contained in:
aaron-jack-manning 2022-08-25 09:26:33 +10:00
parent 2e85db87c1
commit 3fc3388e36
2 changed files with 19 additions and 2 deletions

View File

@ -72,6 +72,7 @@ pub fn time_per_tag(days : u16, vault_folder : &path::Path) -> Result<(), error:
table.set_header(vec!["Tag", "Time"]); table.set_header(vec!["Tag", "Time"]);
let mut total_duration = tasks::Duration::zero();
for (tag, duration) in times { for (tag, duration) in times {
table.add_row( table.add_row(
vec![ vec![
@ -79,8 +80,17 @@ pub fn time_per_tag(days : u16, vault_folder : &path::Path) -> Result<(), error:
duration.to_string(), duration.to_string(),
] ]
); );
total_duration = total_duration + duration;
} }
table.add_row(
vec![
String::from("Total"),
total_duration.to_string(),
]
);
println!("{}", table); println!("{}", table);
Ok(()) Ok(())

View File

@ -273,9 +273,16 @@ impl Task {
// Sort entries by date. // Sort entries by date.
entries.sort_by(|e1, e2| e1.logged_date.cmp(&e2.logged_date)); entries.sort_by(|e1, e2| e1.logged_date.cmp(&e2.logged_date));
println!("Time Entries:"); let mut total = Duration::zero();
let mut lines = Vec::with_capacity(entries.len());
for entry in &entries { for entry in &entries {
println!(" {} [{}]", entry.duration, entry.logged_date); lines.push(format!(" {} [{}]", entry.duration, entry.logged_date));
total = total + entry.duration;
}
println!("Time Entries (totaling {}):", total);
for line in lines {
println!("{}", line);
} }
} }