jellyfin/MediaBrowser.Controller/Library/TVUtils.cs

50 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Diagnostics.CodeAnalysis;
2018-12-28 00:27:57 +01:00
namespace MediaBrowser.Controller.Library
{
/// <summary>
/// Class TVUtils.
2018-12-28 00:27:57 +01:00
/// </summary>
public static class TVUtils
{
/// <summary>
/// Gets the air days.
/// </summary>
/// <param name="day">The day.</param>
/// <returns>List{DayOfWeek}.</returns>
[return: NotNullIfNotNull("day")]
2021-05-07 00:52:06 +02:00
public static DayOfWeek[]? GetAirDays(string? day)
2018-12-28 00:27:57 +01:00
{
if (!string.IsNullOrEmpty(day))
{
if (string.Equals(day, "Daily", StringComparison.OrdinalIgnoreCase))
{
return new[]
{
DayOfWeek.Sunday,
DayOfWeek.Monday,
DayOfWeek.Tuesday,
DayOfWeek.Wednesday,
DayOfWeek.Thursday,
DayOfWeek.Friday,
DayOfWeek.Saturday
};
2018-12-28 00:27:57 +01:00
}
if (Enum.TryParse(day, true, out DayOfWeek value))
2018-12-28 00:27:57 +01:00
{
return new[]
{
value
};
2018-12-28 00:27:57 +01:00
}
2020-07-04 17:54:25 +02:00
return Array.Empty<DayOfWeek>();
2018-12-28 00:27:57 +01:00
}
2020-06-15 23:43:52 +02:00
2018-12-28 00:27:57 +01:00
return null;
}
}
}