RecurrenceCalculator 3.0.2

dotnet add package RecurrenceCalculator --version 3.0.2
NuGet\Install-Package RecurrenceCalculator -Version 3.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RecurrenceCalculator" Version="3.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RecurrenceCalculator --version 3.0.2
#r "nuget: RecurrenceCalculator, 3.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RecurrenceCalculator as a Cake Addin
#addin nuget:?package=RecurrenceCalculator&version=3.0.2

// Install RecurrenceCalculator as a Cake Tool
#tool nuget:?package=RecurrenceCalculator&version=3.0.2

Recurrence Calculator

Library written for .NET that perform Outlook style recurrence calculations. The key to usage is the IRecurrence interface that allows you to specify the recurrence pattern.

I have used for the most part the interface that Outlook supports. You can find the details on MSDN site: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.recurrencepattern(v=office.15).aspx I made one change - I changed the DayOfWeekMask from flags based enumeration to just 7 flags - one for each day of the week. This will allow you to easily expose the same class at the user interface to allow the user to set flags for the days of the week. In order to support things like day, week day and weekend, you just set appropriate days flags. For example, set all the flags for the "day", Sunday and Saturday for the "weekend". I also decided not to support "no end date", so date is required or number of occurrences.

It is very easy to use. Implement IRecurrence in any of your class, create an instance of the calculator, and call Calculate method. An exception will be thrown if your pattern is invalid. You can also call Validate manually. If you get an empty string, you are valid. Otherwise you will get the message telling you what is wrong with your pattern.

The project includes tests that will tell you how to use the calculator. There is now support for default recurrence class and recurrence fluent API builder

private Calculator calendarUtility;
private readonly DateTime startDate = new DateTime(2014, 1, 31, 16, 0, 0);

[TestInitialize]
public void Setup()
{
    calendarUtility = new Calculator();
}

private AppointmentRecurrence CreateWeeklyRecurrence()
{
    return new AppointmentRecurrence
    {
        RecurrenceType = RecurrenceType.Weekly,
        Interval = 2,
        Sunday = false,
        Monday = false,
        Tuesday = true,
        Wednesday = false,
        Thursday = true,
        Friday = false,
        Saturday = false,
        StartDate = startDate,
        Occurrences = 5
    };
}

[TestMethod]
public void Should_Generate_Weekly_Recurrences_Without_End_Date()
{
    var recurrence = CreateWeeklyRecurrence();
    var occurrences = calendarUtility.CalculateOccurrences(recurrence).ToList();
    Assert.AreEqual(5, occurrences.Count, "Should create 5 occurrences");
    Assert.AreEqual(new DateTime(2014, 2, 11).Add(startDate.TimeOfDay), occurrences[0], "Date 1 should be correct");
    Assert.AreEqual(new DateTime(2014, 2, 13).Add(startDate.TimeOfDay), occurrences[1], "Date 2 should be correct");
    Assert.AreEqual(new DateTime(2014, 2, 25).Add(startDate.TimeOfDay), occurrences[2], "Date 3 should be correct");
    Assert.AreEqual(new DateTime(2014, 2, 27).Add(startDate.TimeOfDay), occurrences[3], "Date 4 should be correct");
    Assert.AreEqual(new DateTime(2014, 3, 11).Add(startDate.TimeOfDay), occurrences[4], "Date 5 should be correct");
}

You can also use NuGet to install the package: https://www.nuget.org/packages/RecurrenceCalculator/ Just type Install-Package RecurrenceCalculator in package manager console window.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.2 3,611 2/1/2023
3.0.1 618 12/28/2022
3.0.0 404 12/2/2022
2.0.0 385 12/2/2022
1.0.6 31,930 1/15/2022
1.0.5 10,927 1/9/2020
1.0.4 686 1/1/2020
1.0.3 27,315 11/11/2014
1.0.2 1,229 7/23/2014
1.0.1 1,131 7/23/2014
1.0.0 1,143 7/20/2014

Version 1 Update to .net 6, but still support netstandard 2.0
Version 2 Adds support for different starting day of the week
Version 3 adds support for .net 7, default recurrance class and recurrence bulder with fluent API
Version 3.0.1 fix issue with monthly recurance when start date is greater than day scheduled