Add total time to view pages
This commit is contained in:
parent
e158378a13
commit
9ef6143dbd
1 changed files with 24 additions and 4 deletions
28
src/app.rs
28
src/app.rs
|
|
@ -646,6 +646,16 @@ impl App {
|
|||
let start_time = format!("{:02}:{:02}", start_local.hour(), start_local.minute());
|
||||
let stop_time = format!("{:02}:{:02}", stop_local.hour(), stop_local.minute());
|
||||
|
||||
// Calculate duration
|
||||
let duration = stop_local.signed_duration_since(start_local);
|
||||
let hours = duration.num_hours();
|
||||
let minutes = duration.num_minutes() % 60;
|
||||
let duration_str = if hours > 0 {
|
||||
format!("({}h {:02}m)", hours, minutes)
|
||||
} else {
|
||||
format!("({}m)", minutes)
|
||||
};
|
||||
|
||||
let display_text = if frame.tags.is_empty() {
|
||||
frame.project.clone()
|
||||
} else {
|
||||
|
|
@ -653,8 +663,8 @@ impl App {
|
|||
};
|
||||
|
||||
let line_text = format!(
|
||||
"\t{} to {} {}",
|
||||
start_time, stop_time, display_text
|
||||
"\t{} to {} {:>9} {}",
|
||||
start_time, stop_time, duration_str, display_text
|
||||
);
|
||||
|
||||
lines.push(line_text);
|
||||
|
|
@ -736,6 +746,16 @@ impl App {
|
|||
let start_time = format!("{:02}:{:02}", start_local.hour(), start_local.minute());
|
||||
let stop_time = format!("{:02}:{:02}", stop_local.hour(), stop_local.minute());
|
||||
|
||||
// Calculate duration
|
||||
let duration = stop_local.signed_duration_since(start_local);
|
||||
let hours = duration.num_hours();
|
||||
let minutes = duration.num_minutes() % 60;
|
||||
let duration_str = if hours > 0 {
|
||||
format!("({}h {:02}m)", hours, minutes)
|
||||
} else {
|
||||
format!("({}m)", minutes)
|
||||
};
|
||||
|
||||
let tags_str = if frame.tags.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
|
|
@ -743,8 +763,8 @@ impl App {
|
|||
};
|
||||
|
||||
lines.push(format!(
|
||||
"\t\t{} to {}{}",
|
||||
start_time, stop_time, tags_str
|
||||
"\t\t{} to {} {:>9}{}",
|
||||
start_time, stop_time, duration_str, tags_str
|
||||
));
|
||||
frame_indices.push(*idx);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue