Yearly Recurrence Not Finding All Instances

I’m using CalendarRecurrence objects to get a list of dates for the occurrence within a specific date range, however in some cases it will won’t show instances of recurrence when it should. In particular, it won’t generate the second occurrence of a yearly recurring event, if only the second occurrence is within the date range. See the following MVP below for details:

var rrule = "DTSTART:20201207T000000\r\nRRULE:FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=7;COUNT=3"
//Friendly Text: "Recur every  year on the December, on the 7th day(s) of the month for a maximum of 3 occurrences."
CalendarRecurrencepattern = CalendarRecurrence.FromiCalendar(rrule);
DateCollection dates = pattern.GenerateOccurrences(startTime, endTime);
var startTime = new DateTime(2021, 11, 28);
var endTime = new DateTime(2021, 12, 31);
DateCollection dates = pattern.GenerateOccurrences(startTime, endTime);
// dates is empty, but should contain 12/07/2021
// However including the first time makes it work:
startTime = new DateTime(2020, 11, 28);
dates = pattern.GenerateOccurrences(startTime, endTime)
// Dates is now the expected value
//Count = 2
//    [0]: {12/7/2020 12:00:00 AM}
//    [1]: {12/7/2021 12:00:00 AM}

This appears to me to be a bug, but is there something I’m doing wrong?

@dmanilaoncourse

Can you please share the working sample along with details of the issue in the form of output and snapshot exhibiting the issue.

@mudassir.fayyaz

Here’s a full working sample:

using Aspose.Email.Calendar.Recurrences;
using System;

namespace MVP_Creator
{
    class Program
    {
        static void Main(string[] args)
        {
            var rrule = "DTSTART:20201207T000000\nRRULE:FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=7;COUNT=3";
            //Friendly Text: "Recur every  year on the December, on the 7th day(s) of the month for a maximum of 3 occurrences."
            CalendarRecurrence pattern = CalendarRecurrence.FromiCalendar(rrule);
            var startTime = new DateTime(2021, 11, 28);
            var endTime = new DateTime(2021, 12, 31);
            DateCollection dates = pattern.GenerateOccurrences(startTime, endTime);
            Console.WriteLine("Length of collection: " + dates.Count);
            dates.ForEach(date => Console.WriteLine(date));
            // dates is empty, but should contain 12/07/2021
            // However including the first time makes it work:
            startTime = new DateTime(2020, 11, 28);
            dates = pattern.GenerateOccurrences(startTime, endTime);
            Console.WriteLine("Length of collection: " + dates.Count);
            dates.ForEach(date => Console.WriteLine(date));
            // Dates is still empty. Expected value:
            //Count = 2
            //    [0]: {12/7/2020 12:00:00 AM}
            //    [1]: {12/7/2021 12:00:00 AM}
        }
    }
}

There now appears to be a new issue. Neither example (with the different start dates) returns any dates. Both are empty, despite the fact that there should be occurrences within the date range. This could mean I’m doing something wrong, but if that’s the case if I have no idea what it is. It looks like my code works according to the documentation.

Screenshot of console output:
image.png (2.4 KB)

@dmanilaoncourse

I have created a ticket with ID EMAILNET-40008 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

1 Like

@mudassir.fayyaz I’m noticing that the issue status is marked as status resolved, does this mean it will be fixed in the next update?

@dmanilaoncourse

The concerned issue has been marked as resolved in upcoming Aspose.Email for .NET 20.12. We will share the good news with you as soon as the product will be shared online.

1 Like

The issues you have found earlier (filed as EMAILNET-40008) have been fixed in this update.

I have the same issues with this exact code snippet and the exact version in which it should be fixed (20.12). Is it possible this problem isn’t fixed yet?

@Samir_I,
I investigated the issues described above and received the expected results with Aspose.Email 20.12 and the latest version as well. Please check the version of Aspose.Email you used and check the issues with the latest version.