|
|
|
|
|
|
|
6.2.1.3
Using the Rules to Implement the Types |
|
|
|
|
|
|
|
|
The above set of rules is sufficient to calculate dates for virtually all days of observance in the Western calendar. This section shows how the various types of observance rules described in section 6.2.1.1. can be implemented by these rules. |
|
|
|
|
|
|
|
|
In the following discussion, the fixed-date rule means the production rule, which assigns constant values to the month and day of the date for any given year. All such functions have the same form in SCDTL, described using the following template function: |
|
|
|
|
|
|
|
|
struct DATE_INFO fixed_date (int year)
{
struct DATE_INFO date;
date.year = year;
date.month = <month constant>;
date.day = <day constant>;
return (date);
} |
|
|
|
|
|
|
|
|
Implementation proceeds as follows: |
|
|
|
 |
|
|
|
|
1.1.) Explicit fixed date. |
|
|
|
 |
|
|
|
|
1.1.1.) Period of less than one year. Implement these as two separate fixed date functions. For the pilgrimages to Fatima, for example, define fatima_may () and fatima_october () using the fixed date template for the starting dates. |
|
|
|
 |
|
|
|
|
1.1.2.) Period of one year. Implement with the fixed-date rule. For Christmas, for example, define christmas () using the fixed date template. |
|
|
|
 |
|
|
|
|
1.1.3.) Period of greater than one year. Implement with the fixed-date rule, and control the year with upper level selection logic. For example, for Liberation Day, define a liberation_day () function using the fixed date template and only ask for the date on the correct years: |
|
|
|
 |
|
|
|
|
if ((year % 5) == 0)
date = liberation_day (year); |
|
|
|
 |
|
|
|
|
1.1.4.) Irregular periods. Implement with the fixed-date rule and control the year by selective input. For large and/or variable numbers of years, reading a file of years would work. For smaller numbers of irregular year numbers, a table would work. The following example shows a hypothetical celebration held on five certain years: |
|
|
|
|
|