Open kostyabek opened 2 years ago
I think the thing wrong here is that you are not triggering the method that calculates occurrences. Try with following code, after some refactor to start and end dates, and added the missing instruction:
var rrule = new RecurrencePattern("FREQ=MONTHLY;UNTIL=20221112T215959Z;WKST=SU");
var startDate = new CalDateTime(new DateTime(2021, 11, 12, 16, 0, 0));
var endDate = new CalDateTime(new DateTime(2021, 11, 12, 17, 0, 0));
var vEvent = new CalendarEvent
{
Start = startDate,
End = endDate,
RecurrenceRules = new List<RecurrencePattern> { rrule },
};
var targetDateTime = new CalDateTime(new DateTime(2021, 11, 12, 16, 0, 0));
vEvent.GetOccurrences(startDate, endDate);
var res = vEvent.OccursAt(targetDateTime); // res should be true here.
I was trying to check whether these two function work as expected, but I have not managed to get a single TRUE from them. As I understand, they return TRUE when these conditions are met: OccursOn - if the date provided is equal to the valid range of dates from CalendarEvent OccursAt - if the date and time of the event are equal to those that indicate its start.
Source code
What am I doing wrong, if I do? Thanks in advance.