Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

DateTime.ordinal

(?::Integer year, ?::Integer yday, ?::Integer hour, ?::Integer minute, ?::Integer second, ?::Integer offset, ?::Integer start) -> ::DateTime
DateTime.ordinal([year=-4712[, yday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]) → datetime

Creates a DateTime object denoting the given ordinal date.

Example
DateTime.ordinal(2001,34) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
DateTime.ordinal(2001,34,4,5,6,'+7')
                          #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
DateTime.ordinal(2001,-332,-20,-55,-54,'+7')
                          #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
See also .now .parse .new .rfc2822 also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0