Recurring event bug
brmckenna opened this issue · 4 comments
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!
Hello,
I just confirmed this same issue exists in the latest version of this library as well.
Thank you!
It seems that this problem is fixed with #598. Didn't analyze in detail, but it seems that previous to #598 the duration of the event was considered to be -1d, so it ended on 2024-04-15, which is before the search start date of 2024-04-16, so it was excluded. With the fix it is considered to have a duration of 0d, so it works now, although the duration might still be wrong (should probably be 1d).
[Edit] The duration of 0d as calculated by #598 is correct according to RFC 5545:
The "DTEND" property for a "VEVENT" calendar component specifies the non-inclusive end of the event.
Thank you for the info!