Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Date.leap?
Date.gregorian_leap?(year) → true or false
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 in the proleptic Gregorian calendar, false otherwise:
Example
Date.gregorian_leap?(2000) # => true Date.gregorian_leap?(2001) # => false
Related: Date.julian_leap?.