Temporal Expressions
The Apache Open For Business recurring events are based on Temporal Expressions - a design proposed by Martin Fowler: Recurring Events for Calendars (pdf). The design is extremely flexible and it allows for arbitrarily complex recurring events.
Overview
Each temporal expression could be considered a rule - like "every Monday" or "the 15th of the month." Temporal expressions can used alone or they can be combined in any of three collection expressions - Union, Intersection, and Difference. A date will match a Union collection if any of its member expressions match (logical OR). A date will match an Intersection collection if all of its member expressions match (logical AND). A date will match a Difference collection if it matches the included member expression and doesn't match the excluded member expression (logical AND NOT).
Some of the basic OFBiz temporal expressions are ranges - which simplifies expression creation. For example, if an event occurs every Monday, Tuesday, and Wednesday, you could create an expression for each day and make them members of a Union expression, or you could use a single Day Of Week Range expression that includes Monday through Wednesday.
Sometimes recurring events need to be rescheduled - like when they fall on a holiday, or when maintenance is being performed. The Substitution expression can be used to reschedule recurring events.
In the temporal expression definitions that follow, the expressions will be shown like this:
Expression(parameter1, parameter2, ...) Collection: Member Expression(parameter1, parameter2, ...) Member Expression(parameter1, parameter2, ...)
Basic Expressions
Range Expressions
MinuteRange(start, end) HourRange(start, end) DayOfWeekRange(start, end) DayOfMonthRange(start, end) MonthRange(start, end) DateRange(start, end)
Range Examples
An event that occurs during the 3 o'clock PM hour:
HourRange(start = 15, end = 15)
An event that occurs on Monday, Tuesday, and Wednesday:
DayOfWeekRange(start = Monday, end = Wednesday)
Day In Month Expression
DayInMonth(day of week, occurance)
Day In Month Examples
An event that occurs on the first Monday of the month:
DayInMonth(Monday, 1)
An event that occurs on the fourth Thursday of the month:
DayInMonth(Thursday, 4)
An event that occurs on the last Saturday of the month:
DayInMonth(Saturday, -1)