leap year day : Date Calculation « Date « Ruby






leap year day



require 'date'

leap_year_day = Date.new(1996, 2, 29)
(leap_year_day << 1).to_s                  # => "1996-01-29"
(leap_year_day >> 1).to_s                  # => "1996-03-29"
(leap_year_day >> 12).to_s                 # => "1997-02-28"
(leap_year_day << 12 * 4).to_s             # => "1992-02-29"

 








Related examples in the same category

1.Subtract 61 days from a date:
2.Add and subtract six months using the >> and << methods.
3.Doing Date Arithmetic
4.Doing DateTime Arithmetic
5.Minus one DateTime from another
6.Move DateTime
7.Counting the Days Since an Arbitrary Date
8.advent calendar
9.Minus DateTime by day
10.Remaining days