|
|
 |
|
|
|
|
date = Nth_DOW_of_month (1, DOW_MONDAY, MONTH_FEBRUARY, year); |
|
|
|
 |
|
|
|
|
2.1.2.) N is fixed by rule. Use the number-of-DOWs rule to obtain the value of N, then apply the Nth-DOW rule. The last Sunday in July is obtained as: |
|
|
|
 |
|
|
|
|
int n;
n = number_of_DOWs_in_month (DOW_SATURDAY, MONTH_JULY, year);
date = Nth_DOW_of_month (n, DOW_SATURDAY, MONTH_JULY, year); |
|
|
|
 |
|
|
|
|
Likewise, the last Sunday but one in August can be obtained as: |
|
|
|
 |
|
|
|
|
n = number_of_DOWs_in_month (DOW_SUNDAY, MONTH_AUGUST, year);
n--;
date = Nth_DOW_of_month (n, DOW_SUNDAY, MONTH_AUGUST, year); |
|
|
|
 |
|
|
|
|
The Nth full weekend variant must be addressed separately by its own special routine, owing to the nature of the additional logical constraints. The third full weekend in July would start on the Saturday calculated by: |
|
|
|
 |
|
|
|
|
date = Nth_full_weekend (3, MONTH_JULY, year); |
|
|
|
 |
|
|
|
|
and end on the following day the Sunday whose date can be determined by simply incrementing date.day, since the day must fall in the month as the preceding day. |
|
|
|
 |
|
|
|
|
2.2.) The date M days before or after the Nth DOW. Use the Nth-DOW rule to obtain the date of the Nth DOW, then calculate the date before or after it using the date-before or date-after rule. The given example of the day five days after the fourth Thursday in November would be realized as: |
|
|
|
 |
|
|
|
|
date1 = Nth_DOW_of_month (4, DOW_THURSDAY, MONTH_NOVEMBER, year);
date2 = date_N_days_after_date (5, &date1); |
|
|
|
 |
|
|
|
|
2.3.) The Mth DOW before or after the Nth DOW of a month. Use the Nth-DOW rule to obtain the date of the Nth DOW. Then use the Nth-DOW-before or -after rule to obtain the date of the Mth DOW. The date of the given example of Kinderzeche, defined as the Saturday before the third Monday in July, gives M = 1 and N = 3, realized as: |
|
|
|
 |
|
|
|
|
date1 = Nth_DOW_of_month (3, DOW_MONDAY, MONTH_JULY, year);
date2 = Nth_DOW_before_date (1, DOW_SATURDAY, &date1); |
|
|
|
|
|