Rolls 'duration_to_string' into pp
This commit is contained in:
parent
4ec95af6d0
commit
002ad36068
@ -11,4 +11,4 @@
|
|||||||
24.143.184.98,Lindsay Cogeco
|
24.143.184.98,Lindsay Cogeco
|
||||||
192.186.110.6,Belleville Cogeco
|
192.186.110.6,Belleville Cogeco
|
||||||
129.222.197.36,Belleville Starlink
|
129.222.197.36,Belleville Starlink
|
||||||
192.168.0.50,Sign
|
192.168.1.50,Lindsay Sign
|
||||||
|
|||||||
@ -18,6 +18,41 @@ use color_eyre::owo_colors::OwoColorize;
|
|||||||
use crossterm::style::Stylize;
|
use crossterm::style::Stylize;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
|
pub fn duration_to_string(to_convert: Duration) -> String {
|
||||||
|
let mut total_seconds = to_convert.as_secs();
|
||||||
|
let mut working_string = String::new();
|
||||||
|
|
||||||
|
if total_seconds > 86400 {
|
||||||
|
// days
|
||||||
|
let num_days = total_seconds / 86400;
|
||||||
|
working_string = format!("{} days", num_days);
|
||||||
|
total_seconds = total_seconds - (num_days * 86400);
|
||||||
|
}
|
||||||
|
|
||||||
|
if total_seconds > 3600 {
|
||||||
|
// hours
|
||||||
|
let num_hours = total_seconds / 3600;
|
||||||
|
if num_hours > 0 {
|
||||||
|
working_string = format!("{} {} hours", working_string, num_hours);
|
||||||
|
total_seconds = total_seconds - (num_hours * 3600);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if total_seconds > 60 {
|
||||||
|
let num_minutes = total_seconds / 60;
|
||||||
|
if num_minutes > 0 {
|
||||||
|
working_string = format!("{} {} minutes", working_string, num_minutes);
|
||||||
|
total_seconds = total_seconds - (num_minutes * 60);
|
||||||
|
}
|
||||||
|
// minutes
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
working_string = format!("{} {} seconds", working_string, total_seconds);
|
||||||
|
|
||||||
|
working_string
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct PPState {}
|
struct PPState {}
|
||||||
|
|
||||||
impl PPState {
|
impl PPState {
|
||||||
@ -185,10 +220,11 @@ impl PPState {
|
|||||||
target_string.red().to_string()
|
target_string.red().to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("{} \t | {} \t | {}\t | Changed {}s ago",
|
println!("{} \t | {} \t | {}\t | Changed {} ago",
|
||||||
target_string,
|
target_string,
|
||||||
current_result.alive,
|
current_result.alive,
|
||||||
current_result.last_rtt, time_since_last_change.as_secs()
|
current_result.last_rtt,
|
||||||
|
duration_to_string(time_since_last_change)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
display_loop_start = now;
|
display_loop_start = now;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user