Skip to content

Scheduling engine to create recurring events for calendars

Notifications You must be signed in to change notification settings

dinindu/ScheduleWidget.Core

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

ScheduleWidget

Scheduling engine to create recurring events for calendars

ScheduleWidget is a scheduling engine that creates recurring events for calendars. It is an implementation based on Martin Fowler's white paper Recurring Events for Calendars in which he describes the software design. This is a complete .NET Core 2.0 rewrite of the popular .NET Framework version. Suppose we want to create a schedule that describes the first Monday of every month:

var builder = new ScheduleBuilder();

var schedule = builder
    .DuringMonth(WeekInterval.First)
    .OnDaysOfWeek(DayInterval.Mon)
    .HavingFrequency(FrequencyType.MonthlyByDayInMonth)
    .Create();

Once we create a Schedule we can ask it questions. The Schedule exposes methods (documented in more detail below) that return schedule occurrences (concrete DateTime value objects) over a defined period of time. Suppose DateTime.Today is 20 December 2030:

var during = new DateRange(DateTime.Today, DateTime.Today.AddMonths(6));

foreach (var date in schedule.Occurrences(during))
{
    Debug.WriteLine(date.ToShortDateString());
}

Output CultureInfo("en-US"):

1/6/2031
2/3/2031
3/3/2031
4/7/2031
5/5/2031
6/2/2031

That's all there is to it. Visit the Project Portal for download instructions, detailed documentation, and code samples.

About

Scheduling engine to create recurring events for calendars

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 60.1%
  • HTML 21.5%
  • CSS 18.4%