fix(calendar): fix recurrent event last date

Fix a bug introduces by #8766b7c
This commit is contained in:
Hivert Quentin
2025-07-08 15:26:09 +02:00
parent 7fa0daea43
commit 3ab86776e2
4 changed files with 13 additions and 1 deletions
@@ -93,11 +93,13 @@
if (until)
{
lastStartDate = until;
lastEndDate = until;
}
else
{
repeatCount = [rrule repeatCount];
if (dayMask == nil)
{
// If there's no day mask, we can compute the date of the last
// occurrence of the recurrent rule.
lastStartDate = [firStart dateByAddingYears: 0 months: 0
@@ -106,6 +108,7 @@
lastEndDate = [firEnd dateByAddingYears: 0 months: 0
days: (interval
* (repeatCount - 1))];
}
}
if (lastStartDate != nil && lastEndDate != nil)
@@ -230,10 +230,11 @@ static inline unsigned iCalDoWForNSDoW (int dow)
else
{
untilStart = [rrule untilDate];
untilEnd = [rrule untilDate];
}
}
if (untilStart != nil)
if (untilStart != nil && untilEnd != nil)
{
if ([untilEnd compare: rStart] == NSOrderedAscending)
// Range starts after last occurrence
@@ -102,11 +102,15 @@
lastEndDate = nil;
until = [rrule untilDate];
if (until)
{
lastStartDate = until;
lastEndDate = until;
}
else
{
repeatCount = [rrule repeatCount];
if (dayMask == nil)
{
// When there's no BYxxx mask, we can find the date of the last
// occurrence.
lastStartDate = [firStart dateByAddingYears: 0 months: 0
@@ -115,6 +119,7 @@
lastEndDate = [firEnd dateByAddingYears: 0 months: 0
days: (interval
* (repeatCount - 1) * 7)];
}
}
if (lastStartDate != nil && lastEndDate != nil)
@@ -80,10 +80,12 @@
if (until)
{
lastStartDate = until;
lastEndDate = until;
}
if (repeatCount > 0)
{
if (lastStartDate == nil && ![rrule hasByMask])
{
// When there's no BYxxx mask, we can find the date of the last
// occurrence.
lastStartDate = [firStart dateByAddingYears: (interval * (repeatCount - 1))
@@ -92,6 +94,7 @@
lastEndDate = [firEnd dateByAddingYears: (interval * (repeatCount - 1))
months: 0
days: 0];
}
referenceDate = firStart;
}