|
|
|
| Listing 6.8 | |
|
|
|
|
Each leap year is associated with two letters of the alphabet, which
define the set of dates on which Sunday occurs, with the first letter
indicating the Sunday date set for January and February and the second
letter indicating the date set for the rest of the year.
E.g., the string "AG" denote a year in which the Sundays occur on:
1, 8, 15, 22, 29 January - from the 'A' set
5, 12, 19, 26 February - from the 'A' set
4, 11, 18, 25 March - from the 'G' set
and so on.
2. The routine uses the fact that dominical letters are related to the
'year type' as defined by the 'year_type ()' routine, as follows:
Year type Dominical letter(s) Common/Leap Year
--------- ------------------- ----------------
1 A Common
2 G Common
3 F Common
4 E Common
5 D Common
6 C Common
7 B Common
8 AG Leap
9 GF Leap
10 FE Leap
11 ED Leap
12 DC Leap
13 CB Leap
14 BA Leap
Hence, if the year type is treated as an index, 'y', then we may observe
that the expression (8 - y) modulo 7 supplies an offset of 0 through 6 which
may be added to 'A' to obtain the first letter, as follows:
y w x
Year Type 8 - y w mod 7 'A'+ x
--------- ------ ------- ------
1 7 0 'A'
2 6 6 'G'
3 5 5 'F'
4 4 4 'E'
5 3 3 'D'
6 2 2 'C'
7 1 1 'B'
The year types 8 through 14 are simply 'folded over' into types
1 through 7 by subtraction.
The second letter is always 'one less' than the first letter, if
the letters are treated as a cyclic permutation, 'A' through 'G',
with 'A' following 'G'.
|
|
|
|
|
|
|
|