-
Notifications
You must be signed in to change notification settings - Fork 247
Description
Note: we are currently on https://github.com/laget-se/ical.net which we just realized was marked archived on 10/14/24. Entering this in case this is an issue in this current library.
The following unit test demonstrates the bug of switching the start/end date on a recurring event where the initial date of 4/15/24 is somehow preserved on the object and GetOccurrences no longer returns the 4/16/2024 occurrence as a result and each occurrence has the incorrect end date of 4/15 from the initial value and a duration of -1.
[Fact]
public async Task ShouldCreateARecurringYearlyEvent()
{
var springAdminEvent = new CalendarEvent
{
Start = new CalDateTime(DateTime.Parse("2024-04-15")),
End = new CalDateTime(DateTime.Parse("2024-04-15")),
RecurrenceRules = new List<RecurrencePattern> { new RecurrencePattern(FrequencyType.Yearly, 1) },
};
var calendar = new Calendar();
calendar.Events.Add(springAdminEvent);
var searchStart = DateTime.Parse("2024-04-15");
var searchEnd = DateTime.Parse("2050-5-31");
var occurrences = calendar.GetOccurrences(searchStart, searchEnd);
Assert.Equal(27, occurrences.Count);
springAdminEvent.Start = new CalDateTime(DateTime.Parse("2024-04-16"));
springAdminEvent.End = new CalDateTime(DateTime.Parse("2024-04-16"));
springAdminEvent.RecurrenceRules = new List<RecurrencePattern> { new RecurrencePattern(FrequencyType.Yearly, 1) };
searchStart = DateTime.Parse("2024-04-16");
searchEnd = DateTime.Parse("2050-5-31");
occurrences = calendar.GetOccurrences(searchStart, searchEnd);
//occurences is 26 here, omitting 4/16/2024
Assert.Equal(27, occurrences.Count);
}
We initially correctly pull back 27 occurrences with 2024 being picked up, and a correct Period StartTime/EndTime
After altering the start/end date on the event we incorrectly pull back 26 occurrences and have an incorrect Period StartTime/EndTime due to somehow the old value of 4/15/2024 being preserved internally to the library. Duration is now -1 on all of the occurrences etc.
Thank you in advance for any insights!


