using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Querying;
using System;
namespace MediaBrowser.Server.Implementations.Sorting
{
public class StartDateComparer : IBaseItemComparer
{
///
/// Compares the specified x.
///
/// The x.
/// The y.
/// System.Int32.
public int Compare(BaseItem x, BaseItem y)
{
return GetDate(x).CompareTo(GetDate(y));
}
///
/// Gets the date.
///
/// The x.
/// DateTime.
private DateTime GetDate(BaseItem x)
{
var hasStartDate = x as LiveTvProgram;
if (hasStartDate != null)
{
return hasStartDate.StartDate;
}
return DateTime.MinValue;
}
///
/// Gets the name.
///
/// The name.
public string Name
{
get { return ItemSortBy.StartDate; }
}
}
}