@ -45,8 +45,8 @@ public class GetPlayoutAlternateSchedulesHandler(IDbContextFactory<TvContext> db
StartMonth = 1,
StartDay = 1,
StartYear = null,
EndMonth = 1,
EndDay = 1,
EndMonth = 12,
EndDay = 31,
EndYear = null
};
@ -839,5 +839,29 @@ public static class AlternateScheduleSelectorTests
result.IsNone.ShouldBeTrue();
}
[Test]
public void LimitToDateRange_December_32nd_Should_Not_Crash()
{
var template = new PlayoutTemplate
DaysOfWeek = AlternateScheduleSelector.AllDaysOfWeek(),
DaysOfMonth = AlternateScheduleSelector.AllDaysOfMonth(),
MonthsOfYear = AlternateScheduleSelector.AllMonthsOfYear(),
LimitToDateRange = true,
StartMonth = 12,
StartDay = 32,
StartYear = 2022,
EndDay = 32,
EndYear = 2023
Option<PlayoutTemplate> result = AlternateScheduleSelector.GetScheduleForDate(
new List<PlayoutTemplate> { template },
new DateTimeOffset(2023, 3, 1, 0, 0, 0, Offset));
result.IsNone.ShouldBeFalse();
@ -50,7 +50,7 @@ public static class AlternateScheduleSelector
// this should only happen with days that are greater than the actual days in the month,
// so roll over to the 1st of the next month
start = new DateTime(startYear, item.StartMonth + 1, 1, 0, 0, 0, DateTimeKind.Local);
start = new DateTime(startYear, item.StartMonth, 1, 0, 0, 0, DateTimeKind.Local).AddMonths(1);
try