New proof of concept for duration_to_string
Explicit declaration of duration_to_string
This commit is contained in:
parent
ee5986fedf
commit
03de859764
@ -8,3 +8,6 @@ env_logger = "0.11"
|
||||
log = "0.4"
|
||||
ansi_term = "0.12"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
|
||||
[[bin]]
|
||||
name = "duration_to_string"
|
||||
@ -1,6 +1,6 @@
|
||||
use std::time::Duration;
|
||||
|
||||
fn duration_to_string(to_convert: Duration) -> String {
|
||||
pub fn duration_to_string(to_convert: Duration) -> String {
|
||||
let mut total_seconds = to_convert.as_secs();
|
||||
let mut working_string = String::new();
|
||||
|
||||
@ -11,7 +11,6 @@ fn duration_to_string(to_convert: Duration) -> String {
|
||||
total_seconds = total_seconds - (num_days * 86400);
|
||||
}
|
||||
|
||||
|
||||
if total_seconds > 3600 {
|
||||
// hours
|
||||
let num_hours = total_seconds / 3600;
|
||||
@ -34,9 +33,9 @@ fn duration_to_string(to_convert: Duration) -> String {
|
||||
|
||||
working_string
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("1m 12s => {}", duration_to_string(Duration::from_secs(72)));
|
||||
println!("1h 1m 12s => {}", duration_to_string(Duration::from_secs(3672)));
|
||||
println!("1d 1h 1m 12s => {}", duration_to_string(Duration::from_secs(90072)));
|
||||
println!("30d 1h 1m 12s => {}", duration_to_string(Duration::from_secs(2595672)));
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user