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.ordinal

Date.ordinal([year=-4712[, yday=1[, start=Date::ITALY]]]) → date

Creates a date object denoting the given ordinal date.

The day of year should be a negative or a positive number (as a relative day from the end of year when negative). It should not be zero.

Example
Date.ordinal(2001)        #=> #<Date: 2001-01-01 ...>
Date.ordinal(2001,34)     #=> #<Date: 2001-02-03 ...>
Date.ordinal(2001,-1)     #=> #<Date: 2001-12-31 ...>

See also ::jd and ::new.

See also .nth_kday ._parse .new! .parse also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1