Date Recurrence Library for .NET/C#

 

It's quite unfortunate stackoverflow is closing down questions like this:

Actually, I wish they changed this policy since the field of "what's best" is constantly changing. Normally, I'd contribute to the question and others would vote on that suggestion. The best answer usually bubbles up to the top and *that* is useful. New libraries are created all the time.

Anyway, for those of you looking for a date recurrence library, I'd like to recommend:

There are others, but I've used this before and works really well. The main class you'll need to work with is the Recurrence  in the EWSoftware.PDI name space. For example:

[Test]
public void test()
{
    var r = new Recurrence();
    r.RecurDaily(2);

    var starting = DateTime.Today;
    var ending = DateTime.Today.AddDays(7);

    var dates = r.InstancesBetween(starting, ending);
    foreach( var occurrence in dates )
    {
        Console.WriteLine(occurrence);
    }
}

OUTPUT:

5/25/2015 12:00:00 AM
5/27/2015 12:00:00 AM
5/29/2015 12:00:00 AM
5/31/2015 12:00:00 AM

Also, if you find it useful, consider making a donation to him. I actually bought a license to his PDI library way back when before he open-sourced it. He's also the author of the VS2013 spell checker plug-in. Legit.

Comments

No comments posted yet.

Leave Your Comment

Title*
Name*
Email (never displayed)
 (will show your gravatar)
Url
Comment*

Please add 3 and 1 and type the answer here:

Preview Your Comment.