ribbles - RecurringInterval 1.0.1.17

C# library for calculating intervals and the duration between days, weeks, fortnights, bimonthly, months, quarters and years

PM> Install-Package RecurringInterval -Version 1.0.1.17 -Source https://www.myget.org/F/ribbles/api/v3/index.json

Copy to clipboard

> nuget.exe install RecurringInterval -Version 1.0.1.17 -Source https://www.myget.org/F/ribbles/api/v3/index.json

Copy to clipboard

> dotnet add package RecurringInterval --version 1.0.1.17 --source https://www.myget.org/F/ribbles/api/v3/index.json

Copy to clipboard
<PackageReference Include="RecurringInterval" Version="1.0.1.17" />
Copy to clipboard
source https://www.myget.org/F/ribbles/api/v3/index.json

nuget RecurringInterval  ~> 1.0.1.17
Copy to clipboard

> choco install RecurringInterval --version 1.0.1.17 --source https://www.myget.org/F/ribbles/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "ribbles" -SourceLocation "https://www.myget.org/F/ribbles/api/v2"
Install-Module -Name "RecurringInterval" -RequiredVersion "1.0.1.17" -Repository "ribbles" 
Copy to clipboard

Build Status

RecurringInterval

C# Library for representing and managing recurring intervals, suitable for calendaring functions.

Supported Intervals

Installation

NuGet Package Manager Console

Run the following command in the NuGet Package Manager console to install the library:

PM> Install-Package RecurringInterval

For more information, visit the Nuget RecurringInterval repository

Usage

var interval = Interval.Create(<Period>, <Date>, <Integer End Day>);
var nextInterval = interval.Next();

Daily

Interval.Create(Period.Daily, <start date>, <days>);

The date argument is always the start date. The interger argument is how many days in the interval.

var interval = Interval.Create(Period.Daily, new DateTime(2017,1,1), 2); //Interval has 2 days
Assert.AreEqual(1, interval.StartDate.Day);
Assert.AreEqual(2, interval.EndDate.Day);
Assert.AreEqual(2, interval.TotalDays);

var next = interval.Next();
Assert.AreEqual(3, next.StartDate.Day);
Assert.AreEqual(4, next.EndDate.Day);
Assert.AreEqual(2, next.TotalDays);

Weekly

Interval.Create(Period.Weekly, <start date>, <day of week to end on>);

The interger is the day of the week to end on, can can be cast from the System.DayOfWeek enum. The date argument is any date between the end date and the start date.

var interval = Interval.Create(Period.Daily, new DateTime(2017, 5, 2), (int)DayOfWeek.Monday /* 2 */);
Assert.AreEqual(new DateTime(2017, 5, 2) interval.StartDate);
Assert.AreEqual(new DateTime(2017, 5, 8), interval.EndDate);
Assert.AreEqual(7, interval.TotalDays);

var next = interval.Next();
Assert.AreEqual(new DateTime(2017, 5, 9) next.StartDate);
Assert.AreEqual(new DateTime(2017, 5, 15), next.EndDate);
Assert.AreEqual(7, next.TotalDays);

Bi-Weekly / Fortnighly

Interval.Create(Period.Daily, <start date>, <ignored>);

The date argument is always the start date. The interger argument is ignored.

Bi-Monthly

Interval.Create(Period.BiMonthly, <start date>, <end day of month>);

This is the most complex, and follows the following conventions for the integer argument end date:

For periods ending on:

  • 1st and 16th of each month: use 1 or 16
  • 2nd and 17th of month: use 2 or 17
  • 3rd and 18th of month: use 3 or 18
  • 4th and 19th of month: use 4 or 19
  • 5th and 20th of month: use 5 or 20
  • 6th and 21st of month: use 6 or 21
  • 7th and 22nd of month: use 7 or 22
  • 8th and 23rd of month: use 8 or 23
  • 9th and 34th of month: use 9 or 24
  • 10th and 25th of month: use 10 or 25
  • 11th and 26th of month: use 11 or 26
  • 12th and 27th of month: use 12 or 27
  • 13th and last day of month: use 13
  • 14th and last day of month: use 14
  • 15th and last day of month: use -1, 15 or 28+

Monthly

Interval.Create(Period.Monthly, <start date>, <day of month to end on>);

Quarterly

Interval.Create(Period.Quarterly, <start date>, <day of quarter to end on>);

Annually

Interval.Create(Period.Annual, <start date>, <day of year to end on>);

Four-Four-Four

See https://en.wikipedia.org/wiki/4%E2%80%934%E2%80%935_calendar for a definition.

Interval.Create(Period.FourFourFour, <start date>, <ignored>);

Four-Four-Five

See https://en.wikipedia.org/wiki/4%E2%80%934%E2%80%935_calendar for a definition.

Interval.Create(Period.FourFourFive, <start date>, <ignored>);
  • .NETFramework 4.0: 4.0.0.0
  • .NETFramework 4.5: 4.5.0.0
  • .NETFramework 4.6: 4.6.0.0
  • .NETFramework 4.6.2: 4.6.2.0

Owners

Ribbles

Authors

https://github.com/ribbles

Project URL

https://github.com/ribbles/RecurringInterval/

License

MIT

Tags

C# .NET DateTime Calendar Duration Interval

Info

317 total downloads
21 downloads for version 1.0.1.17
Download (89.64 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.0.1.17 89.64 KB Tue, 01 Aug 2017 23:03:50 GMT 21
1.0.1.16 103.25 KB Tue, 01 Aug 2017 01:22:52 GMT 15
1.0.1.14 92.67 KB Fri, 02 Jun 2017 21:39:07 GMT 22
1.0.1.13 92.67 KB Wed, 31 May 2017 13:07:57 GMT 20
1.0.1.12 35.98 KB Tue, 30 May 2017 00:35:11 GMT 18
1.0.1.11 35.92 KB Tue, 30 May 2017 00:25:28 GMT 24
1.0.1.10 35.95 KB Tue, 30 May 2017 00:25:22 GMT 22
1.0.1.9 5.7 KB Mon, 29 May 2017 23:26:52 GMT 14
1.0.1.8 5.7 KB Mon, 29 May 2017 18:24:13 GMT 16
1.0.1.7 5.69 KB Mon, 29 May 2017 18:24:00 GMT 13
1.0.1.6 5.7 KB Mon, 29 May 2017 18:04:13 GMT 19
1.0.1.5 5.7 KB Mon, 29 May 2017 18:04:01 GMT 13
1.0.1.4 5.7 KB Mon, 29 May 2017 17:48:37 GMT 30
1.0.1.3 5.7 KB Mon, 29 May 2017 01:02:00 GMT 20
1.0.1.2 6.37 KB Mon, 29 May 2017 00:40:17 GMT 8
1.0.0-CI00001 6.35 KB Mon, 29 May 2017 00:28:59 GMT 21
1.0.0-CI00000 6.34 KB Sun, 28 May 2017 23:51:53 GMT 21