Skip to content
Merged
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
22 changes: 22 additions & 0 deletions Ical.Net.Tests/TodoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
// Licensed under the MIT license.
//

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Ical.Net.CalendarComponents;
using Ical.Net.DataTypes;
using NUnit.Framework;

Expand Down Expand Up @@ -218,4 +220,24 @@ public void Todo7_1()
occurrences,
Has.Count.EqualTo(items.Count));
}

[Test, Category("Todo")]
public void Todo_WithFutureStart_AndNoDuration_ShouldSucceed()
{
var today = CalDateTime.Today;

var todo = new Todo
{
Start = today,
RecurrenceRules = [new RecurrencePattern("FREQ=DAILY")]
};

// periodStart is in the future, so filtering the first occurrence will also require
// looking at the todo's duration, which is unset/null. It must therefore be ignored.
var firstOccurrence = todo.GetOccurrences(today.AddDays(2)).FirstOrDefault();

Assert.That(firstOccurrence, Is.Not.Null);
Assert.That(firstOccurrence.Period.StartTime, Is.Not.Null);
Assert.That(firstOccurrence.Period.Duration, Is.Null);
}
}
2 changes: 1 addition & 1 deletion Ical.Net/Evaluation/RecurrenceUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ from p in periods
let effectiveEndTime = p.EffectiveEndTime
where
p.StartTime.GreaterThanOrEqual(periodStart)
|| effectiveEndTime.GreaterThan(periodStart)
|| ((effectiveEndTime != null) && effectiveEndTime.GreaterThan(periodStart))
select p;
}

Expand Down
Loading