From b7e160f735be468bf1023c4816af705a61297dbb Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Thu, 21 Dec 2017 21:50:50 +0200 Subject: [PATCH] EpisodeWidget: Change date representation based on it's year. Closes #19. --- hammond-gtk/src/widgets/episode.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hammond-gtk/src/widgets/episode.rs b/hammond-gtk/src/widgets/episode.rs index 00e0f8e..da74711 100644 --- a/hammond-gtk/src/widgets/episode.rs +++ b/hammond-gtk/src/widgets/episode.rs @@ -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();