October 2006
Intermediate to advanced
888 pages
16h 55m
English
The Date class has two class methods julian_leap? and gregorian_leap?; only the latter is of use in recent years. It also has a method leap?, which is an alias for the gregorian_leap? method.
require "date" flag1 = Date.julian_leap? 1700 # true flag2 = Date.gregorian_leap? 1700 # false flag3 = Date.leap? 1700 # false
Every child knows the first rule for leap years: The year number must be divisible by four. Fewer people know the second rule, that the year number must not be divisible by 100; and fewer still know the exception, that the year can be divisible by 400. In other words: A century year is a leap year only if it is divisible by 400, so 1900 was not a leap year, but 2000 was. (This adjustment is necessary because ...
Read now
Unlock full access