< previous page page_140 next page >

Page 140
#include "scdtl_2.h"
struct DATE_INFO advent (int year)
 {
    struct DATE_INFO date1, date2;
    date1 = make_date (year, MONTH_NOVEMBER, 30);
    date2 = DOW_closest_to_date (DOW_SUNDAY, &date1);
    return (date2);
 }
6.2.2.5
Nth-DOW-Before or -After Date
The date for the Feast of the Holy Family is celebrated within the Roman Catholic Church as a movable feast on the Sunday after Epiphany and is intended to commemorate the Holy Family as a group.
This section presents two approaches to the calculation of this date. The first approach is a direct one for the date itself, whereas the second illustrates the use of the utility ensemble. The first algorithm works by starting with 6 January and obtaining the index of the day of the week on which it falls. The term (7 - index) is the number of days that must be added to obtain the following Sunday. For example, if the index is 6, Saturday, then (7 6 =) 1 day must be added to 6 January to obtain 7 January, the Sunday following. If the index is 0, then 6 January is Sunday itself, and you must skip to the following Sunday, which is done by adding (7 0 =) 7 days to obtain 13 January, the next Sunday.
#include "scdtl_2.h"
struct DATE_INFO holy_family (int year)
 {
    int index;
    double jd;
    struct DATE_INFO date;


    date.year = year;
    date.month = 1;
    date.day = 6;
    jd = date_to_JD0 (&date);
    index = day_of_week_index_JD0 (jd);
    jd += (double) (7 - index);
    date = JD0_to_date (jd);


    return (date);
 }
The second approach to calculating this day of observance uses the utility functions, as follows:

 
< previous page page_140 next page >