EpisodeWidget: Fix minutes label parsing.
Before if a feed had reported a number between 1 and 60, a label 0 min would be set. This fixes that, while also using chrono::Duration for parsing minutes.
This commit is contained in:
parent
ea29aae64a
commit
fbfa0de17e
@ -4,6 +4,7 @@ use gtk;
|
|||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
|
||||||
|
use chrono::Duration;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use humansize::{file_size_opts as size_opts, FileSize};
|
use humansize::{file_size_opts as size_opts, FileSize};
|
||||||
use open;
|
use open;
|
||||||
@ -187,16 +188,16 @@ impl EpisodeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set the duration label.
|
/// Set the duration label.
|
||||||
fn set_duration(&self, seconds: Option<i32>) {
|
fn set_duration(&self, seconds: Option<i32>) -> Option<()> {
|
||||||
if (seconds == Some(0)) || seconds.is_none() {
|
let minutes = Duration::seconds(seconds?.into()).num_minutes();
|
||||||
return;
|
if minutes == 0 {
|
||||||
};
|
return None;
|
||||||
|
|
||||||
if let Some(secs) = seconds {
|
|
||||||
self.duration.set_text(&format!("{} min", secs / 60));
|
|
||||||
self.duration.show();
|
|
||||||
self.separator1.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.duration.set_text(&format!("{} min", minutes));
|
||||||
|
self.duration.show();
|
||||||
|
self.separator1.show();
|
||||||
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the Episode label dependings on its size
|
/// Set the Episode label dependings on its size
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user