From c4f1888e42d596296b0319cd65d5e8dbf26b758d Mon Sep 17 00:00:00 2001 From: Markus Minichmayr Date: Sun, 20 Oct 2024 22:38:28 +0200 Subject: [PATCH] RRULE Evaluation: Apply `BYYEARDAY=366` only in leap years. --- Ical.Net/Evaluation/RecurrencePatternEvaluator.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Ical.Net/Evaluation/RecurrencePatternEvaluator.cs b/Ical.Net/Evaluation/RecurrencePatternEvaluator.cs index 937c9455..dc466fe0 100644 --- a/Ical.Net/Evaluation/RecurrencePatternEvaluator.cs +++ b/Ical.Net/Evaluation/RecurrencePatternEvaluator.cs @@ -467,7 +467,9 @@ private List GetYearDayVariants(List dates, RecurrencePatter var date1 = date; yearDayDates.AddRange(pattern.ByYearDay.Select(yearDay => yearDay > 0 ? date1.AddDays(-date1.DayOfYear + yearDay) - : date1.AddDays(-date1.DayOfYear + 1).AddYears(1).AddDays(yearDay))); + : date1.AddDays(-date1.DayOfYear + 1).AddYears(1).AddDays(yearDay)) + // Ignore the BY values that don't fit into the current year (i.e. +-366 in non-leap-years). + .Where(d => d.Year == date1.Year)); } return yearDayDates; } @@ -483,7 +485,7 @@ private List GetYearDayVariants(List dates, RecurrencePatter ? date.AddDays(-date.DayOfYear + yearDay) : date.AddDays(-date.DayOfYear + 1).AddYears(1).AddDays(yearDay); - if (newDate.DayOfYear == date.DayOfYear) + if (newDate.Date == date.Date) { goto Next; }