I have been developing, for grins, a job scheduling calendar for an imaginary landscaping company using FulllCalendar with a WordPress plugin as the backend. One of the more common problems encountered is recurring events. First issue is an interface for the user to define the recurrences and second is processing them.
From my perspective recurrences are a combination of a pattern and an interval. Perhaps there is a case for a hybrid of the two too.
Thus a recurrence can be defined in terms of months of the year (moy), weeks of the month (wom), and days of the week (dow), An example is Thanksgiving Day; “Every year the last Thursday of November”, moy = November, wom = last and finally the dow = Thursday.
Another common recurrence is Christmas which also occurs annually on the 25th of December or day 25 of the month of December (dom)
We can use these arrays to define the recurrences
- moy array(0..11) of bool
- dom array(0..30) of bool
- wom array(0..4) of bool note array set alone (0001) indicates the last dow for the month.
- dow array(0..6) of bool
Next adding an interval unit array(0..3) for days,weeks, and months coupled with a multiplier value we can round out the necessary elements to define recurrences.
The following views show the user interface to define recurring events;
This above is the default view expressing the event start date. This a pattern that does not have an explicit interval.
This is a weekly interval recurring event view where the days of the week can be set. Thus the week can have a pattern for the days of the week.
This is an event with a monthly occurrence where the weeks of the months and days of the month may be set.
This is another event with a monthly occurrence but here the dates of the month may be selected.