RecurrenceCalculator 1.0.6

.NET 6.0 .NET Standard 2.0
Install-Package RecurrenceCalculator -Version 1.0.6
dotnet add package RecurrenceCalculator --version 1.0.6
<PackageReference Include="RecurrenceCalculator" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RecurrenceCalculator --version 1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RecurrenceCalculator, 1.0.6"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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=1.0.6

// Install RecurrenceCalculator as a Cake Tool
#tool nuget:?package=RecurrenceCalculator&version=1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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: 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.

<pre><code class='language-cs'>

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"); } </code></pre>

You can also use NuGet to install the package: Just type Install-Package RecurrenceCalculator in package manager console window.

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

    • No dependencies.
  • net6.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
1.0.6 932 1/15/2022
1.0.5 8,333 1/9/2020
1.0.4 415 1/1/2020
1.0.3 18,935 11/11/2014
1.0.2 939 7/23/2014
1.0.1 839 7/23/2014
1.0.0 832 7/20/2014

Update to .net 6, but still support netstandard 2.0