Skip to content

Commit

Permalink
RRULE Evaluation: Apply BYYEARDAY=366 only in leap years. (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
minichma authored Oct 24, 2024
1 parent 36f2666 commit 2146ea0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Ical.Net/Evaluation/RecurrencePatternEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ private List<DateTime> GetYearDayVariants(List<DateTime> 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;
}
Expand All @@ -500,7 +502,7 @@ private List<DateTime> GetYearDayVariants(List<DateTime> 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;
}
Expand Down

0 comments on commit 2146ea0

Please sign in to comment.