Dec. 4, 2014
3:28 p.m.
On Dec 3, 2014, at 12:33 PM, Hilaire <hilaire@drgeo.eu> wrote:
Le 02/12/2014 17:34, Sean P. DeNigris a écrit :
One solution (just ignore the source ha ha) - http://msdn.microsoft.com/en-us/library/system.datetime.addyears%28v=vs.110%...
Something like ?
Date>>addYears: integer ^ Date year: self year + integer month: self monthIndex day: ((self dayOfMonth = 29 and: [(Year isLeapYear: self year + integer) not and: [Year isLeapYear: self year]]) ifTrue: [ 28 ] ifFalse: [ self dayOfMonth])
From a brief read of the code it looks like the day formula should have a check for monthIndex == 2. Otherwise, January 29 can turn in to January 28.