Incorrect dates calculated by Weekly recurrence

APPLIES TO
Aspose.Recurrence 1.1.3 and earlier versions.

OVERVIEW
When using Weekly recurrence it is possible to specify a combination of days of week and recurrence start date that will result in wrong occurrence dates calculated.

TO REPRODUCE
public void TestSundayBug()
{
Weekly recur = new Weekly(1);
//This combination of start date and days if week will result in incorrect dates.
recur.StartDate = new DateTime(2003, 12, 15);
recur.DaysOfWeek.SetDayOn(System.DayOfWeek.Monday, true);
recur.DaysOfWeek.SetDayOn(System.DayOfWeek.Sunday, true);

recur.MaxOccurrences = 10;
DateArray dates = new DateArray();
recur.GenerateOccurrences(recur.StartDate, DateTime.MaxValue, dates);

Assertion.AssertEquals(10, dates.Count);
//At the moment it generates 12/15, 12/22, 12/22, 12/29, 12/29.
//Below are correct dates that should be returned by the component.
Assertion.AssertEquals(new DateTime(2003, 12, 15), dates[0]);
Assertion.AssertEquals(new DateTime(2003, 12, 21), dates[1]);
Assertion.AssertEquals(new DateTime(2003, 12, 22), dates[2]);
Assertion.AssertEquals(new DateTime(2003, 12, 28), dates[3]);
Assertion.AssertEquals(new DateTime(2003, 12, 29), dates[4]);
}

WORKAROUND
Change start date of the recurrence pattern. In the above example if start date was changed to 2003/12/14 for example, the problem would disappear.

We are working on this issue at the moment and will post when it is resolved.

Note that occurrence dates for a weekly pattern can be calculated out of the chronological order due to the way Weekly class works internally. This is easy to workaround, you can just sort the DateArray if you need to. We will address this in the fix too and always return chronologically sorted dates.

Hi,

This issue has been fixed in Aspose.Recurrence 1.1.4.0.

For more details please see https://forum.aspose.com/t/46666#3456.