Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Ical.Net.Tests/TodoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Linq;
using Ical.Net.CalendarComponents;
using Ical.Net.DataTypes;
using NodaTime;
using NUnit.Framework;

namespace Ical.Net.Tests;
Expand Down Expand Up @@ -238,4 +239,33 @@ public void Todo_WithFutureStart_AndNoDuration_ShouldSucceed()
Assert.That(firstOccurrence, Is.Not.Null);
Assert.That(firstOccurrence.Start, Is.EqualTo(firstOccurrence.End));
}

[Test, Category("Todo")]
public void Todo_RecurrenceWithNoEnd_IsCompletedUntilNextOccurrence()
{
var start = new CalDateTime(2026, 1, 15, 0, 0, 0, "UTC");

var todo = new Todo
{
Start = start,
RecurrenceRules = [new("FREQ=DAILY;BYDAY=TH")],
};

todo.Status = "COMPLETED";
todo.Completed = new CalDateTime(new LocalDate(2026, 1, 16)
.AtMidnight()
.InUtc()
.ToInstant());

var results = Enumerable.Range(14, 10)
.Select(x => new LocalDate(2026, 1, x))
.Select(x => todo.IsCompleted(x.AtMidnight().InUtc()))
.ToList();

// Jan 14-21: true (8 days) - TODO is considered completed
// Jan 22-23: false (2 days) - TODO is NOT completed
List<bool> expected = [true, true, true, true, true, true, true, true, false, false];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Jan 14-21: true (8 days) - TODO is considered completed
// Jan 22-23: false (2 days) - TODO is NOT completed


Assert.That(results, Is.EquivalentTo(expected));
}
}
2 changes: 1 addition & 1 deletion Ical.Net/Evaluation/TodoEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
DetermineStartingRecurrence(Todo.RecurrenceDates.GetAllDates()
.Select(x => x.ToZonedDateTime(completedDate.Zone)), ref beginningDate);

foreach (var exrule in Todo.ExceptionRules)

Check warning on line 39 in Ical.Net/Evaluation/TodoEvaluator.cs

View workflow job for this annotation

GitHub Actions / coverage

'RecurringComponent.ExceptionRules' is obsolete: 'EXRULE is marked as deprecated in RFC 5545 and will be removed in a future version'

Check warning on line 39 in Ical.Net/Evaluation/TodoEvaluator.cs

View workflow job for this annotation

GitHub Actions / tests

'RecurringComponent.ExceptionRules' is obsolete: 'EXRULE is marked as deprecated in RFC 5545 and will be removed in a future version'
{
DetermineStartingRecurrence(exrule, ref beginningDate);
}
Expand All @@ -50,7 +50,7 @@
}

return Evaluate(Todo.Start, beginningDate, options)
.Where(p => p.Start.ToInstant() <= currDt.ToInstant());
.TakeWhile(p => p.Start.ToInstant() <= currDt.ToInstant());
}

private static void DetermineStartingRecurrence(IEnumerable<EvaluationPeriod> rdate, ref ZonedDateTime referenceDateTime)
Expand Down
Loading