Skip to content

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

class method

Date.valid_date?

Date.valid_civil?(year, month, mday, start = Date::ITALY) → true or false

Returns true if the arguments define a valid ordinal date, false otherwise:

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

See argument start.

Date.valid_date? is an alias for Date.valid_civil?.

Related: Date.jd, Date.new.