End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Date.leap?
Date.gregorian_leap?(year) → bool
Date.leap?(year) → bool
ext/date/date_core.c
View on GitHub ↗
static VALUE
date_s_gregorian_leap_p(VALUE klass, VALUE y)
{
VALUE nth;
int ry;
check_numeric(y, "year");
decode_year(y, -1, &nth, &ry);
return f_boolcast(c_gregorian_leap_p(ry));
}
Returns true if the given year is a leap year of the proleptic Gregorian calendar.
Example
Date.gregorian_leap?(1900) #=> false Date.gregorian_leap?(2000) #=> true