commit e6590c09cf6298fb13c7aa8c68b53e1efaf6dff5
parent 92344a5263cfb6b9bdd5a543be3dd6ab96025537
Author: tomvig38@gmail.com <tomvig38@gmail.com>
Date: Thu, 4 Nov 2021 15:53:39 +0000
Korektu la vidita komando
Diffstat:
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/main.rs b/src/main.rs
@@ -203,23 +203,24 @@ fn vidita_update(channel: &str, nomo: &str, msg: &str) {
}
fn formato_dauxro(dato: Duration) -> String {
- let mut res = String::with_capacity(10);
let inter: Vec<(i64, &'static str)> = vec![
(dato.num_days(), "tago"),
(dato.num_hours() % 24, "horo"),
- (dato.num_minutes() % 60, "horo"),
+ (dato.num_minutes() % 60, "minuto"),
(dato.num_seconds() % 60, "sekondo"),
];
- for (n, v) in inter {
- if n == 1 {
- res.push_str(&format!("{} {}", n, v));
- } else if n > 1 {
- res.push_str(&format!("{} {}j", n, v));
+ let inter: Vec<String> = inter.iter().filter_map(|(n, v)| {
+ if *n == 1 {
+ Some(format!("{} {}", n, v))
+ } else if *n > 1 {
+ Some(format!("{} {}j", n, v))
+ } else {
+ None
}
- }
+ }).collect();
- res
+ inter.join(" ")
}
fn vidita_display(channel: &str, nomo: &str) -> Option<String> {