Added ToBestDateString for DateTime, using on Series/Details.

pull/6/head
Mark McDowall 13 years ago
parent 5f0a95b2b1
commit 9271b39787

@ -125,6 +125,7 @@
<virtualDirectory path="/" physicalPath="%NZBDRONE_PATH%\NZBDrone.Web" /> <virtualDirectory path="/" physicalPath="%NZBDRONE_PATH%\NZBDrone.Web" />
</application> </application>
<bindings> <bindings>
<binding protocol="http" bindingInformation="*:8989:localhost" />
<binding protocol="http" bindingInformation="*:8989:" /> <binding protocol="http" bindingInformation="*:8989:" />
</bindings> </bindings>
</site> </site>

@ -28,5 +28,22 @@ namespace NzbDrone.Core
{ {
return gigabytes * 1073741824L; 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();
}
} }
} }

@ -4,6 +4,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
using MvcMiniProfiler; using MvcMiniProfiler;
using NzbDrone.Core;
using NzbDrone.Core.Helpers; using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Jobs; using NzbDrone.Core.Providers.Jobs;
@ -199,7 +200,7 @@ namespace NzbDrone.Web.Controllers
var airDate = String.Empty; var airDate = String.Empty;
if (e.AirDate != null) if (e.AirDate != null)
airDate = e.AirDate.Value.ToShortDateString(); airDate = e.AirDate.Value.ToBestDateString();
episodes.Add(new EpisodeModel episodes.Add(new EpisodeModel
{ {

Loading…
Cancel
Save