Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Date.valid_civil?

Date.valid_civil?(year, month, mday[, start=Date::ITALY]) → bool
Date.valid_date?(year, month, mday[, start=Date::ITALY]) → bool

Returns true if the given calendar date is valid, and false if not. Valid in this context is whether the arguments passed to this method would be accepted by ::new.

Example
Date.valid_date?(2001,2,3)        #=> true
Date.valid_date?(2001,2,29)       #=> false
Date.valid_date?(2001,2,-1)       #=> true

See also ::jd and ::civil.