On Friday 21 July 2017 03:01 PM, Tim Mackinnon wrote:
Actually that simplification doesnât work - someone born on 1/Mar/2000 should be 11 on 1/Mar/2011 and this answers 10 (the previous version did work).
You're right. The simplification does not take into account leap days. Mea culpa. Original code (dropping +1) is readable and simple. Regards .. Subbu
This does make me think its tricky enough to put this in the core - I may submit it along with the unit tests I borrowed from Stack Overflow (the shame)â¦
Its a good problem though. Thanks for discussing it with me.
Tim
On 21 Jul 2017, at 10:09, K K Subbu <kksubbu.ml@gmail.com <mailto:kksubbu.ml@gmail.com>> wrote:
^aDate year - self year - (aDate dayOfYear < self dayOfYear) ifTrue: [ 1 ] ifFalse: [ 0 ])