The CalendarRule component is used to perform date calculations based on working time, rather than chronological time. For example, the CalendarRule component understands 24h as three working days if the Organization's calendar rule specifies that a working day consists of eight hours.
Use the static method CalendarRule.add(...) to calculate the next working date based on a start date and interval. The component checks the date against the calendar rules defined in Process Administrator for the current process' Organization and Organizational Unit, and returns a future date based on these rules.
An instance of CalendarRule represents a particular rule defined in Process Administrator. Use the methods fetch() and fetchAll() to load CalendarRule objects.
You cannot create new calendar rules or modify existing rules using the CalendarRule component.
In this example, the CalendarRule component is used to obtain the next working date after Christmas Eve:
xmasEve = Time.valueOf(year: 2005, month: 12, dayOfMonth: 24,
hourOfDay: 12, minute : 0, second : 0)
nextWorkingDate = CalendarRule.add(date : xmasEve + '1d', interval : '1s')
display "Christmas Eve: " + format(xmasEve, dateStyle : Time.FULL, timeStyle : Time.LONG) +
"\nChristmas : " + format(xmasEve + '1d', dateStyle : Time.FULL, timeStyle : Time.LONG) +
"\nNext Working date: " + format(nextWorkingDate, dateStyle : Time.FULL, timeStyle : Time.LONG)