Read Me - Common Public License V1.0 - Copyright Notice(©)

addYears


>>-addYears(years)--------------------------------------------><

Add a number of years to the DateTime object, returning a new DateTime instance. The receiver DateTime object is unchanged. The [years] value must be a valid whole number. Negative values result in years being subtracted from the DateTime value.

The addYears method will take leap years into account. If the addition result would fall on February 29th of a non-leap year, the day will be rolled back to the 28th.

Class DATETIME - addYears method


date = .DateTime~new(2008, 2, 29)
say date              -- Displays "2008-02-29T00:00:00.000000"
say date~addYears(1)  -- Displays "2009-02-29T00:00:00.000000"

Read Me - Common Public License V1.0 - Copyright Notice(©)