Pad the left side of hours/minutes/seconds with 0 and handle no description

master
blank X 2 years ago
parent 64763e014f
commit 71727a7b6f
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5

2
Cargo.lock generated

@ -202,7 +202,7 @@ dependencies = [
[[package]]
name = "hanimers"
version = "0.1.6"
version = "0.1.7"
dependencies = [
"clap",
"quick-xml",

@ -1,6 +1,6 @@
[package]
name = "hanimers"
version = "0.1.6"
version = "0.1.7"
authors = ["blank X <theblankx@protonmail.com>"]
edition = "2018"

@ -135,15 +135,18 @@ impl fmt::Display for HentaiInfo {
}
let mut duration = String::new();
if hours > 0 {
duration.push_str(&format!("{}:", hours));
duration.push_str(&format!("{:02}:", hours));
}
if minutes > 0 {
duration.push_str(&format!("{}:", minutes));
duration.push_str(&format!("{:02}:", minutes));
}
duration.push_str(&seconds.to_string());
text.push_str(&format!("Duration: {}\n", &duration));
text.push_str(&format!("Duration: {}{:02}\n", &duration, seconds));
}
formatter.write_str(&format!("{}Tags: {}\nDescription: {}", &text, video.hentai_tags.iter().map(|i| i.text.as_str()).collect::<Vec<_>>().join(", "), &video.description))
text.push_str(&format!("Tags: {}", video.hentai_tags.iter().map(|i| i.text.as_str()).collect::<Vec<_>>().join(", ")));
if !video.description.is_empty() {
text.push_str(&format!("\nDescription: {}", &video.description));
}
formatter.write_str(&text)
}
}

Loading…
Cancel
Save