Year Y is a leap year if Y is perfectly divisible by 4, and
The following sources follow the rule above:
calendar.monthrange(1000,2)
is (5, 28))However, the following sources say 1000 was a leap year:
cal 2 1000
displays 29 days)The Gregorian system was introduced in 1582, where the rule above apparently started to apply (before 1582, the only requirement was perfect division by 4). However, testing several other year values (100, 500, 600, 700, 900, 1100, 1300, 1400, 1500 and 1700) indicate that only after and including 1800 the results of Python and Linux cal agree.
Why do these sources give different answers?
The calendar
module uses the proleptic Gregorian calendar.
From the calendar
docs:
Most of these functions and classes rely on the
datetime
module which uses an idealized calendar, the current Gregorian calendar extended in both directions. This matches the definition of the “proleptic Gregorian” calendar in Dershowitz and Reingold’s book “Calendrical Calculations”, where it’s the base calendar for all computations.
From Wikipedia:
The proleptic Gregorian calendar is produced by extending the Gregorian calendar backward to dates preceding its official introduction in 1582.
The Julian calendar was not replaced by the Gregorian calendar on a single date. It was adopted by various countries at different times.
From the Linux cal
man page on my (rather ancient) machine:
-s -file ... -country_code
Assume the switch from Julian to Gregorian Calendar at the date associated with the country_code If not specified,
ncal
tries to guess the switch date from the local environment or falls back to September 2, 1752. This was when Great Britain and her colonies switched to the Gregorian Calendar.[...]
BUGS
The assignment of Julian–Gregorian switching dates to country codes is historically naive for many countries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With