@@ -49,9 +49,9 @@ static class RecurrenceEvaluator
4949 const string Numbered = "Numbered" ;
5050 const string NoEnd = "NoEnd" ;
5151
52- const int WeeklyUnitIntervalDuration = 7 ; // in days
53- const int MonthlyUnitIntervalDuration = 28 ; // in days
54- const int YearlyUnitIntervalDuration = 365 ; // in days
52+ const int WeekDayNumber = 7 ;
53+ const int MinMonthDayNumber = 28 ;
54+ const int MinYearDayNumber = 365 ;
5555
5656 public static bool MatchRecurrence ( DateTimeOffset time , TimeWindowFilterSettings settings )
5757 {
@@ -619,13 +619,13 @@ private static bool TryValidateWeeklyRecurrencePattern(TimeWindowFilterSettings
619619
620620 RecurrencePattern pattern = settings . Recurrence . Pattern ;
621621
622- TimeSpan intervalDuration = TimeSpan . FromDays ( pattern . Interval * WeeklyUnitIntervalDuration ) ;
622+ TimeSpan intervalDuration = TimeSpan . FromDays ( pattern . Interval * WeekDayNumber ) ;
623623
624624 TimeSpan timeWindowDuration = settings . End . Value - settings . Start . Value ;
625625
626626 //
627627 // Time window duration must be shorter than how frequently it occurs
628- if ( settings . End . Value - settings . Start . Value > intervalDuration )
628+ if ( timeWindowDuration > intervalDuration )
629629 {
630630 paramName = $ "{ nameof ( settings . End ) } ";
631631
@@ -684,7 +684,7 @@ private static bool TryValidateAbsoluteMonthlyRecurrencePattern(TimeWindowFilter
684684
685685 RecurrencePattern pattern = settings . Recurrence . Pattern ;
686686
687- TimeSpan intervalDuration = TimeSpan . FromDays ( pattern . Interval * MonthlyUnitIntervalDuration ) ;
687+ TimeSpan intervalDuration = TimeSpan . FromDays ( pattern . Interval * MinMonthDayNumber ) ;
688688
689689 //
690690 // Time window duration must be shorter than how frequently it occurs
@@ -730,7 +730,7 @@ private static bool TryValidateRelativeMonthlyRecurrencePattern(TimeWindowFilter
730730
731731 RecurrencePattern pattern = settings . Recurrence . Pattern ;
732732
733- TimeSpan intervalDuration = TimeSpan . FromDays ( pattern . Interval * MonthlyUnitIntervalDuration ) ;
733+ TimeSpan intervalDuration = TimeSpan . FromDays ( pattern . Interval * MinMonthDayNumber ) ;
734734
735735 //
736736 // Time window duration must be shorter than how frequently it occurs
@@ -782,7 +782,7 @@ private static bool TryValidateAbsoluteYearlyRecurrencePattern(TimeWindowFilterS
782782
783783 RecurrencePattern pattern = settings . Recurrence . Pattern ;
784784
785- TimeSpan intervalDuration = TimeSpan . FromDays ( pattern . Interval * YearlyUnitIntervalDuration ) ;
785+ TimeSpan intervalDuration = TimeSpan . FromDays ( pattern . Interval * MinYearDayNumber ) ;
786786
787787 //
788788 // Time window duration must be shorter than how frequently it occurs
@@ -833,7 +833,7 @@ private static bool TryValidateRelativeYearlyRecurrencePattern(TimeWindowFilterS
833833
834834 RecurrencePattern pattern = settings . Recurrence . Pattern ;
835835
836- TimeSpan intervalDuration = TimeSpan . FromDays ( pattern . Interval * YearlyUnitIntervalDuration ) ;
836+ TimeSpan intervalDuration = TimeSpan . FromDays ( pattern . Interval * MinYearDayNumber ) ;
837837
838838 //
839839 // Time window duration must be shorter than how frequently it occurs
0 commit comments