Giter Site home page Giter Site logo

rachitman / schedulewidget Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamesstill/schedulewidget

0.0 1.0 0.0 5.49 MB

ScheduleWidget handles recurring events for calendars

License: MIT License

C# 43.08% Batchfile 0.01% CSS 6.64% ASP 0.02% JavaScript 47.79% PowerShell 2.46%

schedulewidget's Introduction

ScheduleWidget handles recurring events for calendars. Let's say we want to create a 
recurring event for the Critical Mass Bicycle Ride, which happens in many major cities
on the last Friday of every month. 

Code Sample:

// using ScheduleWidget.Enums; 
// using ScheduleWidget.ScheduledEvents; 
var aEvent = new Event() 
{ 
    ID = 1, 
	Title = "Critical Mass Bicycle Ride", 
	FrequencyTypeOptions = FrequencyTypeEnum.Monthly, 
	MonthlyIntervalOptions = MonthlyIntervalEnum.Last, 
	DaysOfWeekOptions = DayOfWeekEnum.Fri
};

=======
ScheduleWidget handles recurring events for calendars.

ScheduleWidget is a .NET scheduling engine that handles recurring events for calendars. I was influenced by Martin Fowler's white paper "Recurring Events for Calendars" in which he describes the broad software architecture for a recurring events scheduling engine. But I did not find any implementation of his idea in the wild. So this led me to write it myself. It's pretty easy to use ScheduleWidget. Suppose you have an event that occurs every Monday and Wednesday. Here's the code:

var aEvent = new Event()
{
    ID = 1,
    Title = "Every Mon and Wed",
    FrequencyTypeOptions = FrequencyTypeEnum.Weekly,    
    DaysOfWeekOptions = DayOfWeekEnum.Mon | DayOfWeekEnum.Wed
};

var schedule = new Schedule(aEvent);

// give me all the upcoming dates for the next year
var range = new DateRange() 
{ 
    StartDateTime = DateTime.Now, 
	EndDateTime = DateTime.Now.AddYears(1) 
}; 

var occurrences = schedule.Occurrences(range);

foreach(var date in occurrences)
{
	System.Diagnostics.Debug.Print(date);
}

Download the ScheduleWidget Sample Project for a fully-functional test harness that
illustrates how best to use the ScheduleWidget engine. The project home page is at:
http://www.squarewidget.com/schedulewidget
=======
Now the schedule object can calculate the calendar dates for the event. Suppose I want to know if the event occurs today:

bool occursToday = schedule.IsOccurring(DateTime.Today);

Or maybe I want to get the dates for the next three months:

var range = new DateRange()
{    
    StartDateTime = DateTime.Today,
    EndDateTime = DateTime.Today.AddMonths(3)
};

IEnumerable<DateTime> dates = schedule.Occurrences(range);

You can model one-time, daily, weekly, bi-weekly, quarterly, monthly, and yearly (anniversary) intervals. You can make exceptions for holidays. It works great with FullCalendar or any other javascript-based calendar control. 

schedulewidget's People

Contributors

jamesstill avatar raghav-khunger avatar jerryjoseph avatar amoerie avatar mm98 avatar blaketnc avatar dajohein avatar danspam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.