|
|
|
|
|
|
|
#include "scdtl_2.h"
struct DATE_INFO holy_family (int year)
{
struct DATE_INFO date1, date2;
date1 = make_date (year, MONTH_JANUARY, 6);
date2 = Nth_DOW_after_date (1, DOW_SUNDAY, &date1);
if (date 1 == date2)
date2 = Nth_DOW_after_date (2, DOW_SUNDAY, &date1);
return (date2);
} |
|
|
|
|
|
|
|
|
Note in this case that the rule for the date does not exactly match the Nth-DOW-after function, requiring an additional check. The rule for the Feast states ''the Sunday following Epiphany", whereas Nth_DOW_after_date () returns "the date on or after a certain date". Hence, if the first Sunday on or after Epiphany is Epiphany itself, then the function must be invoked again to obtain the second Sunday. Unlike the DOW-closest example above, the rule for the date is not inclusive and does not exactly match the behavior of the function. |
|
|
|
|
|
|
|
|
Where a day of observance can be defined by a rule at all, the utility ensemble should provide the necessary tools to provide for its implementation in code. In more complex cases, several of the utility functions may need to be combined in order to obtain the desired result. |
|
|
|
|
|
|
|
|
One of the more complex examples of a rule defining a day of observance is that for Kinderzeche, which defines the Saturday before the third Monday in July. |
|
|
|
|
|
|
|
|
The following example shows how a function for this date can be easily constructed in a modular way, using the utility functions: |
|
|
|
|
|
|
|
|
#include "scdtl_2.h"
struct DATE_INFO kinderzeche (int year)
{
struct DATE_INFO date1, date2;
date1 = Nth_DOW_of_month (3, DOW_MONDAY, MONTH_JULY, year);
date2 = Nth_DOW_before_date (1, DOW_SATURDAY, &date1);
return (date2);
} |
|
|
|
|
|