EpisodeWidget: Change date representation based on it's year. Closes #19.

This commit is contained in:
Jordan Petridis 2017-12-21 21:50:50 +02:00
parent 4a033e6d89
commit b7e160f735
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6

View File

@ -124,10 +124,13 @@ impl EpisodeWidget {
}
};
let date = Utc.timestamp(i64::from(episode.epoch()), 0)
.format("%b %e")
.to_string();
self.date.set_text(&date);
let now = Utc::now();
let date = Utc.timestamp(i64::from(episode.epoch()), 0);
if now.year() == date.year() {
self.date.set_text(&date.format("%e %b").to_string());
} else {
self.date.set_text(&date.format("%e %b %Y").to_string());
};
// Show or hide the play/delete/download buttons upon widget initialization.
let local_uri = episode.local_uri();