Program: MKLEAPYEAR
mkleapyear................is yr a leap year (366 days) ?
call: k=mkleapyear(yr);
k=mkleapyear(yr,typ);
yr: number of the year (e.g. 1995)
negative years are years before christ
(year 0 does not exist!)
typ: calendar type
'greg': gregorian calendar
'jul': julian calendar
'auto': uses gregorian after 1582 and julian for all other years.
default: 'greg' (chosen for backward compatibility)
result: k: 1: year is a leap year (366 days)
2: year is a regular year (365 days)
NaN: yr zero: this year does not exist in the greg. calendar!
a warning will occur in this case.
(the result is used by other algorithms which make
these strange values necessary)
In the gregorian calendar, a year is a leap year if its number is
divisible by 4, except centuries whose number is NOT divisible by 400.
1992, 1996, 2000 are leap years, 1700,1800,1900,2100 are not.
The century rule does not apply in the julian calendar, where all years
divisible by four are leap years.
An interesting problem is, that both the julian and greogorian calendars do
not contain a year zero: years are numbered ...4BC, 3BC, 2BC, 1BC, 1, 2, 3,...
- the divisible-by-four rule does not apply for years before christ (BC),
because the fourth year before 4 is 1BC, which is obsviouly not divisible by 4
(or anything else)!
This function fixes this problem by adding one to negative years and
applying the calendar rules afterwards.
uses the switch construct and will therefore not run under MatLab
versions before 5.0
Martin Knapmeyer 29.05.1995, 24.01.1999
parameter typ invented MK04.05.1999
Read M-File Source Code
eof.