aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Library/TVUtils.cs
blob: 968338dc6a5025123332cffeaf271ec871943b80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Diagnostics.CodeAnalysis;

namespace MediaBrowser.Controller.Library
{
    /// <summary>
    /// Class TVUtils.
    /// </summary>
    public static class TVUtils
    {
        /// <summary>
        /// Gets the air days.
        /// </summary>
        /// <param name="day">The day.</param>
        /// <returns>List{DayOfWeek}.</returns>
        [return: NotNullIfNotNull("day")]
        public static DayOfWeek[]? GetAirDays(string? day)
        {
            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
                    };
                }

                if (Enum.TryParse(day, true, out DayOfWeek value))
                {
                    return new[]
                    {
                        value
                    };
                }

                return Array.Empty<DayOfWeek>();
            }

            return null;
        }
    }
}