|
|
|
| Listing 5.3 gregorian_leap_year() | |
|
|
|
|
/* grleapyr.c
+-------------------------------------------+
| Copyright (C) 1995 by Lance W. Latham. |
| All rights reserved. |
+-------------------------------------------+
Determines whether a given year is a leap year, by the Gregorian
calendar rule.
INPUTS:
1. year, type int, a year in the Western calendar system. Valid
values are positive and negative integers, including zero.
OUTPUTS:
1. Returned by routine, type int, an indicator whether the input
year is a leap year, by the Gregorian rule:
1 = input year IS a leap year, by the Gregorian rule.
0 = input year IS NOT a leap year, by the Gregorian rule.
NOTES:
1. The input year is assumed to be a 'complete' year. I.e., '89'
represents the year A.D. 89, not 1989. Negative years represent
years 'B.C.', by the rule '-N' corresponds to 'N+l B.C.'.
2. The leap year rule applied by this routine is the Gregorian
calendar rule, which states that a year IS a leap year if it
is evenly divisible by 4, but IS NOT a leap year if it is evenly
divisible by 100, but IS a leap year if it is evenly divisible
by 400.
3. While use of this routine is strictly accurate only for years
after 1582, it may used to apply the Gregorian leap year rule
to years prior to 1583, since the routine does not enforce the
year prohibition. Thus, the routine is more general, and can
be used for Gregorian proleptic calendar applications. Note that
1582 is not a leap year by either the Gregorian or Julian rule.
4. This function is used as a utility be other functions in this
series.
5. Note that the routine returns '1' or '0', not 'TRUE' and 'FALSE'.
The intentional return of these values allows dates and tables
to be incremented by simply arithmetically adding the value
returned by this routine.
|
|
|
|
|
|
|
|