From 71727a7b6f54d7ce1afb88de616269736bae83ee Mon Sep 17 00:00:00 2001 From: blank X Date: Tue, 23 Mar 2021 12:52:04 +0700 Subject: [PATCH] Pad the left side of hours/minutes/seconds with 0 and handle no description --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/structs.rs | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b904a6..8d08528 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "hanimers" -version = "0.1.6" +version = "0.1.7" dependencies = [ "clap", "quick-xml", diff --git a/Cargo.toml b/Cargo.toml index da9a47c..4806fb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hanimers" -version = "0.1.6" +version = "0.1.7" authors = ["blank X "] edition = "2018" diff --git a/src/structs.rs b/src/structs.rs index 7d39c88..99add07 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -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::>().join(", "), &video.description)) + text.push_str(&format!("Tags: {}", video.hentai_tags.iter().map(|i| i.text.as_str()).collect::>().join(", "))); + if !video.description.is_empty() { + text.push_str(&format!("\nDescription: {}", &video.description)); + } + formatter.write_str(&text) } }