2020-08-22 14:29:54 -07:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 13:01:16 -07:00
|
|
|
using System;
|
2020-05-12 19:10:35 -07:00
|
|
|
using Jellyfin.Data.Enums;
|
2018-12-27 16:27:57 -07:00
|
|
|
|
2020-05-12 19:10:35 -07:00
|
|
|
namespace Jellyfin.Data
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
|
|
|
public static class DayOfWeekHelper
|
|
|
|
{
|
2021-03-08 21:57:38 -07:00
|
|
|
public static DayOfWeek[] GetDaysOfWeek(DynamicDayOfWeek day)
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
2021-03-08 21:57:38 -07:00
|
|
|
return day switch
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
2021-03-13 14:40:23 -07:00
|
|
|
DynamicDayOfWeek.Everyday => new[] { DayOfWeek.Sunday, DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday },
|
2021-03-09 09:01:14 -07:00
|
|
|
DynamicDayOfWeek.Weekday => new[] { DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday },
|
|
|
|
DynamicDayOfWeek.Weekend => new[] { DayOfWeek.Sunday, DayOfWeek.Saturday },
|
2021-03-08 21:57:38 -07:00
|
|
|
_ => new[] { (DayOfWeek)day }
|
|
|
|
};
|
2018-12-27 16:27:57 -07:00
|
|
|
}
|
2023-02-08 15:55:26 -07:00
|
|
|
|
|
|
|
public static bool Contains(this DynamicDayOfWeek dynamicDayOfWeek, DayOfWeek dayOfWeek)
|
|
|
|
{
|
|
|
|
return dynamicDayOfWeek switch
|
|
|
|
{
|
|
|
|
DynamicDayOfWeek.Everyday => true,
|
2023-02-09 00:50:44 -07:00
|
|
|
DynamicDayOfWeek.Weekday => dayOfWeek is >= DayOfWeek.Monday and <= DayOfWeek.Friday,
|
2023-02-08 15:55:26 -07:00
|
|
|
DynamicDayOfWeek.Weekend => dayOfWeek is DayOfWeek.Saturday or DayOfWeek.Sunday,
|
|
|
|
_ => (DayOfWeek)dynamicDayOfWeek == dayOfWeek
|
|
|
|
};
|
|
|
|
}
|
2018-12-27 16:27:57 -07:00
|
|
|
}
|
|
|
|
}
|