5 Purpose: Determine if a given year is a leap year. Algorithm
\r
6 taken from C Programmer's Toolkit, Jack Purdum, Que
\r
10 int year The year to test
\r
13 int 1 if the year is a leap year, 0 otherwise
\r
15 int Dates::IsLeapYear(int year)
\r
17 if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
\r
18 return 1; // It is a leap year
\r
20 return 0; // not a leap year
\r
25 Purpose: Determine the date for Easter for a given year.
\r
26 Algorithm taken from Beginning Object Oriented
\r
27 Programming with C#, Jack Purdum, Wrox, 2012.
\r
30 struct easter *myData Pointer to an easter structure
\r
35 CAUTION: This function assumes that the year member of the structure holds the
\r
36 year being tested upon entry.
\r
39 void Dates::GetEaster(Dates *myData){ // This is line 44
\r
43 int temp1, temp2, total;
\r
45 myData->myEaster.easterStr[0] = '0'; // Always a '0'
\r
46 myData->myEaster.easterStr[2] = '/'; // Always a '/'
\r
47 myData->myEaster.easterStr[3] = '0'; // Assume day is less than 10
\r
48 myData->myEaster.easterStr[10] = '\0'; // null char for End of string
\r
50 offset = myData->myEaster.year % 19;
\r
51 leap = myData->myEaster.year % 4;
\r
52 day = myData->myEaster.year % 7;
\r
53 temp1 = (19 * offset + 24) % 30;
\r
54 temp2 = (2 * leap + 4 * day + 6 * temp1 + 5) % 7;
\r
55 total = (22 + temp1 + temp2);
\r
57 myData->myEaster.easterStr[1] = '4'; // Must be in April
\r
58 myData->myEaster.month = 4; // Save the month
\r
61 myData->myEaster.easterStr[1] = '3'; // Must be in March
\r
62 myData->myEaster.month = 3; // Save the month
\r
65 myData->myEaster.day = day; // Save the day
\r
67 if (day < 10) { // One day char or two?
\r
68 myData->myEaster.easterStr[4] = (char) (day + ASCIIZERO);
\r
70 itoa(day, myData->myEaster.easterStr + 3, 10); // Convert day to ASCII and...
\r
72 myData->myEaster.easterStr[5] = '/'; // Always a '/' and overwrites null from itoa()
\r
73 itoa(myData->myEaster.year, myData->myEaster.easterStr + 6, 10); // Convert year to ASCII...
\r