Browse Source

feedback

pull/2757/head
Jason Dove 7 months ago
parent
commit
ce4516feb3
No known key found for this signature in database
  1. 4
      ErsatzTV.Application/Playouts/Queries/GetPlayoutAlternateSchedulesHandler.cs
  2. 24
      ErsatzTV.Core.Tests/Scheduling/AlternateScheduleSelectorTests.cs
  3. 2
      ErsatzTV.Core/Scheduling/AlternateScheduleSelector.cs

4
ErsatzTV.Application/Playouts/Queries/GetPlayoutAlternateSchedulesHandler.cs

@ -45,8 +45,8 @@ public class GetPlayoutAlternateSchedulesHandler(IDbContextFactory<TvContext> db @@ -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
};

24
ErsatzTV.Core.Tests/Scheduling/AlternateScheduleSelectorTests.cs

@ -839,5 +839,29 @@ public static class AlternateScheduleSelectorTests @@ -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,
EndMonth = 12,
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();
}
}
}

2
ErsatzTV.Core/Scheduling/AlternateScheduleSelector.cs

@ -50,7 +50,7 @@ public static class AlternateScheduleSelector @@ -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

Loading…
Cancel
Save