From 9271b39787ffd240d258f2699aed73082c86b316 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 27 Sep 2011 17:10:08 -0700 Subject: [PATCH] Added ToBestDateString for DateTime, using on Series/Details. --- IISExpress/AppServer/applicationhost.config | 1 + NzbDrone.Core/Fluent.cs | 17 +++++++++++++++++ NzbDrone.Web/Controllers/SeriesController.cs | 3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/IISExpress/AppServer/applicationhost.config b/IISExpress/AppServer/applicationhost.config index f1e3a3538..0c97c0b67 100644 --- a/IISExpress/AppServer/applicationhost.config +++ b/IISExpress/AppServer/applicationhost.config @@ -125,6 +125,7 @@ + diff --git a/NzbDrone.Core/Fluent.cs b/NzbDrone.Core/Fluent.cs index cd5ce56db..2a36a393f 100644 --- a/NzbDrone.Core/Fluent.cs +++ b/NzbDrone.Core/Fluent.cs @@ -28,5 +28,22 @@ namespace NzbDrone.Core { return gigabytes * 1073741824L; } + + public static string ToBestDateString(this DateTime dateTime) + { + if (dateTime == DateTime.Today.AddDays(-1)) + return "Yesterday"; + + if (dateTime == DateTime.Today) + return "Today"; + + if (dateTime == DateTime.Today.AddDays(1)) + return "Tomorrow"; + + if (dateTime > DateTime.Today.AddDays(1) && dateTime < DateTime.Today.AddDays(7)) + return dateTime.DayOfWeek.ToString(); + + return dateTime.ToShortDateString(); + } } } diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index 713e7ad1d..d96ad4387 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Web.Mvc; using MvcMiniProfiler; +using NzbDrone.Core; using NzbDrone.Core.Helpers; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Jobs; @@ -199,7 +200,7 @@ namespace NzbDrone.Web.Controllers var airDate = String.Empty; if (e.AirDate != null) - airDate = e.AirDate.Value.ToShortDateString(); + airDate = e.AirDate.Value.ToBestDateString(); episodes.Add(new EpisodeModel {