Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug #3041046 - Interval = 0 results in infinite loop

  • Loading branch information...
commit af9e1e964038c786178d944845fc20fe3d908c2d 1 parent 70a06c5
dougday authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 DDay.iCal/Evaluation/Evaluator.cs
View
5 DDay.iCal/Evaluation/Evaluator.cs
@@ -65,6 +65,10 @@ protected IDateTime ConvertToIDateTime(DateTime dt, IDateTime referenceDate)
protected void IncrementDate(ref DateTime dt, IRecurrencePattern pattern, int interval)
{
+ // FIXME: use a more specific exception.
+ if (interval <= 0)
+ throw new Exception("Cannot evaluate with an interval of zero (or less). Please use an interval greater than zero.");
+
DateTime old = dt;
switch (pattern.Frequency)
{
@@ -75,6 +79,7 @@ protected void IncrementDate(ref DateTime dt, IRecurrencePattern pattern, int in
case FrequencyType.Weekly: dt = DateUtil.AddWeeks(Calendar, old, interval, pattern.FirstDayOfWeek); break;
case FrequencyType.Monthly: dt = old.AddDays(-old.Day + 1).AddMonths(interval); break;
case FrequencyType.Yearly: dt = old.AddDays(-old.DayOfYear + 1).AddYears(interval); break;
+ // FIXME: use a more specific exception.
default: throw new Exception("FrequencyType.NONE cannot be evaluated. Please specify a FrequencyType before evaluating the recurrence.");
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.