Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Date#year
() -> ::Integer
year → integer
ext/date/date_core.c
View on GitHub ↗
static VALUE
d_lite_year(VALUE self)
{
get_d1(self);
return m_real_year(dat);
}
Returns the year:
Example
Date.new(2001, 2, 3).year # => 2001 (Date.new(1, 1, 1) - 1).year # => 0