Added ToBestDateString for DateTime, using on Series/Details.

This commit is contained in:
Mark McDowall 2011-09-27 17:10:08 -07:00
parent 5f0a95b2b1
commit 9271b39787
3 changed files with 20 additions and 1 deletions

View File

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

View File

@ -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();
}
}
}

View File

@ -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
{