Skip to content

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

instance method

Date#prev_year

d.prev_year([n=1]) → date

This method is equivalent to d << (n * 12).

Example
Date.new(2001,2,3).prev_year      #=> #<Date: 2000-02-03 ...>
Date.new(2008,2,29).prev_year     #=> #<Date: 2007-02-28 ...>
Date.new(2008,2,29).prev_year(4)  #=> #<Date: 2004-02-29 ...>

See also Date#<<.

See also #prev_month #rfc2822 #prev_day #rfc3339 also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0