Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeating "Events" (Calendar)

I'm currently working on an application that allows people to schedule "Shows" for an online radio station.

I want the ability for the user to setup a repeated event, say for example:-

"Manic Monday" show - Every Monday From 9-11 "Mid Month Madness" - Every Second Thursday of the Month "This months new music" - 1st of every month.

What, in your opinion, is the best way to model this (based around an MVC/MTV structure).

Note: I'm actually coding this in Django. But I'm more interested in the theory behind it, rather than specific implementation details.

like image 269
Mez Avatar asked Jul 12 '09 12:07

Mez


1 Answers

Ah, repeated events - one of the banes of my life, along with time zones. Calendaring is hard.

You might want to model this in terms of RFC2445. However, that may well give you far more flexibility - and complexity than you really want.

A few things to consider:

  • Do you need any finer granularity than a certain time on given dates? If you need to repeat based on time as well, it becomes trickier.
  • Consider date corner cases such as "the 30th of every month" and what that means for leap years
  • Consider time corner cases such as "1.30am every day" - sometimes 1.30am may happen twice, and sometimes it may not happen at all, due to daylight saving time
  • Do you need to share the schedule with people in other time zones? That makes life trickier again
  • Do you need to represent the number of times an event occurs, or a final date on which it occurs? ("Count" or "until" basically.) You may not need either, or you may need one or both.

I realise this is a list of things to think about more than a definitive answer, but I think it's important to define the parameters of your problem before you try to work out a solution.

like image 56
Jon Skeet Avatar answered Nov 15 '22 10:11

Jon Skeet