Product Site

5.4.6.38. addYears

Returns a new DateTime instance with a number of years added to the timestamp. The receiving instance is unchanged. The years value must be a valid whole number. Negative values result in years being subtracted.

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.
Example 5.237. DateTime class — addYears method
date = .DateTime~new(2016, 6, 30)
say date              -- displays "2016-06-30T00:00:00.000000"
say date~addYears(1)  -- displays "2017-06-30T00:00:00.000000"