From 4cff9b85120032057178f224f06730e019715b8b Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Sat, 30 May 2020 20:37:46 -0400 Subject: [PATCH] Clea up IsParentalScheduleAllowed --- Jellyfin.Data/Entities/User.cs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Jellyfin.Data/Entities/User.cs b/Jellyfin.Data/Entities/User.cs index 1098cdb2f..ac87c7ec2 100644 --- a/Jellyfin.Data/Entities/User.cs +++ b/Jellyfin.Data/Entities/User.cs @@ -458,24 +458,14 @@ namespace Jellyfin.Data.Entities return GetPreference(PreferenceKind.GroupedFolders).Any(i => new Guid(i) == id); } - private bool IsParentalScheduleAllowed(AccessSchedule schedule, DateTime date) + private static bool IsParentalScheduleAllowed(AccessSchedule schedule, DateTime date) { - if (date.Kind != DateTimeKind.Utc) - { - throw new ArgumentException("Utc date expected"); - } - var localTime = date.ToLocalTime(); - - return DayOfWeekHelper.GetDaysOfWeek(schedule.DayOfWeek).Contains(localTime.DayOfWeek) && - IsWithinTime(schedule, localTime); - } - - private bool IsWithinTime(AccessSchedule schedule, DateTime localTime) - { var hour = localTime.TimeOfDay.TotalHours; - return hour >= schedule.StartHour && hour <= schedule.EndHour; + return DayOfWeekHelper.GetDaysOfWeek(schedule.DayOfWeek).Contains(localTime.DayOfWeek) + && hour >= schedule.StartHour + && hour <= schedule.EndHour; } // TODO: make these user configurable?