From 146c7ac4bf58059771d1da24ab3a60a76d35ba2d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 24 Oct 2013 13:49:24 -0400 Subject: fix double path concatenation --- .../Sorting/AirTimeComparer.cs | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 MediaBrowser.Server.Implementations/Sorting/AirTimeComparer.cs (limited to 'MediaBrowser.Server.Implementations/Sorting') diff --git a/MediaBrowser.Server.Implementations/Sorting/AirTimeComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AirTimeComparer.cs new file mode 100644 index 000000000..46c3df07b --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/AirTimeComparer.cs @@ -0,0 +1,48 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.TV; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; +using System; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + public class AirTimeComparer : IBaseItemComparer + { + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// System.Int32. + public int Compare(BaseItem x, BaseItem y) + { + return DateTime.Compare(GetValue(x), GetValue(y)); + } + + /// + /// Gets the value. + /// + /// The x. + /// System.String. + private DateTime GetValue(BaseItem x) + { + var series = (x as Series) ?? x.FindParent(); + + DateTime result; + if (series != null && DateTime.TryParse(series.AirTime, out result)) + { + return result; + } + return DateTime.MinValue; + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.AirTime; } + } + } +} -- cgit v1.2.3