Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create recurring calendar events?

I am using asp mvc 3, jquery full calendar, ms sql sever 2008 and c#.

I am wondering if anyone knows how to make recurring events?

I am unsure how to make them.

For instance in google calendar you can make an appointment repeat yearly forever. I doubt that they generate that appointment X times in the database.

I am wondering how I could have one row in my db and somehow know to call that up when needed.

Also google calendar and outlook have lots of repeating options like repeat on the 1st month, last month and etc.

Is there any libraries build that have this? Or do I got to make it from scratch?

P.S

I am on a shared host so a solution has to work with limited rights.

like image 306
chobo2 Avatar asked Feb 09 '11 19:02

chobo2


People also ask

How do I create a recurring calendar event in Outlook?

Go to the Calendar in the navigation pane. In the ribbon, select "New Appointment" or open an existing appointment from the calendar to add recurrence information to. In the "Options" group in the ribbon inside the appointment, click "Recurrence." The Appointment Recurrence window will open.

How do I automatically add events from one calendar to another?

Click Import & Export in the settings, and you'll find the Import option. Select the file you just exported from the other calendar, then choose the calendar you'd like to import the dates to. You've now imported all of your events.


1 Answers

Generating all possible repetitions of an event would (in theory) fill up your storage with events that would most likely never ever be seen by the user (congrats on your 999,999,999,999,999,999,999th birthday!).

It takes a bit more work, but the solution is to basically store a table (or tables) of repetition rules which you link your calendar entries to as you build a calendar:

"for every day of the week being shown, check for events which repeat on those days" "for every week of the month being shown, check for events which repeat in those weeks" "for every month in a year", etc...

How many of these checks you have to do depends on how many types (and duration) of repetitions you'd want.

As for supressing events, that's yet another table listing points at dates/times which have to be supressed. "if showing mondays, show all events that repeat on months, except the ones listed in the supression table"

comment followup:

Well, you'd have your standard calendar entry table, to store the core information. date/time, etc... Then at least two other tables to store the repeat information. One that stores your repetition rules. "every monday", "first day of month", "every year", etc..., and a third table that links between the calendar entries and the the rules

so:

 calendar entries table  <--->  link table  <--->  repeat rules table

Querying would be a matter of building things so that for the date you're considering, the appropriate rules come out and give you the IDs of calendar entries to display. Could get ugly if you do a fancy query that dynamically links to the appropriate rules based on a date you've passed in.

like image 166
Marc B Avatar answered Oct 01 '22 08:10

Marc B