Cool! I found this because my birthday hasn't occurred yet this year. I was wondering if I had forgotten how old I was
On Tue, Sep 23, 2014 at 1:09 PM, robert therriault <[email protected]> wrote: > Hi Joe, > > Turns out it was a quick fix and that I that my test results for > > 1900 2 1 age 1899 3 1 > > and > > 2000 2 1 age 1999 3 1 > > were faulty and should have caught this. In this version they have been > updated and New Years Eve baby test has been added in your honour! > > Cheers, bob > > age =: 3 : 0 NB. age in yyyy mm dd as of x if born on y > 'left argument is today ; right argument is birth day result is age in > yyyy mm dd' > : > if. x <&(1000#.]) y do. 'Wasn''t born yet!' return. end. > 'yb mb db'=. y > 'yt mt dt'=. x > ly=. 2 | +/ 0= 4 100 400 | yb > dcount=. 31 , (28 + ly ) , 31 30 31 30 31 31 30 31 30 31 > ((yt-yb) - mt<mb) , ((12|mt-mb) - dt<db) , ((mt-2){dcount )|dt-db > ) > testdate =: 3 : 0 > assert. 0 0 0 -: 2000 2 28 age 2000 2 28 NB. same date > assert. 0 0 1 -: 2000 1 1 age 1999 12 31 NB. New Years Eve baby (Joe > Bogner) > assert. 0 0 1 -: 2000 3 2 age 2000 3 1 NB. event and current after feb 29 > in leap year > assert. 0 0 1 -: 2000 2 28 age 2000 2 27 NB. event and current before feb > 29 in leap year > assert. 0 0 2 -: 2000 3 1 age 2000 2 28 NB. event before and current after > feb 29 in leap year > assert. 'Wasn''t born yet!' -: 2000 2 28 age 2000 3 1 NB. event before > current in leap year > assert. 0 0 1 -: 1900 3 2 age 1900 3 1 NB. event and current after feb 28 > in non leap year > assert. 0 0 1 -: 1900 2 28 age 1900 2 27 NB. event and current before feb > 28 in non leap year > assert. 0 0 1 -: 1900 3 1 age 1900 2 28 NB. event before and current after > feb 28 in leap non year > assert. 'Wasn''t born yet!' -: 1900 2 28 age 1900 3 1 NB. event before > current in non leap year > assert. 1 0 1 -: 2000 3 2 age 1999 3 1 NB. event previous year and current > after feb 29 in leap year > assert. 1 0 1 -: 2000 2 28 age 1999 2 27 NB. event previous year and > current before feb 29 in leap year > assert. 1 0 1 -: 2000 3 1 age 1999 2 28 NB. event previous year before and > current after feb 29 in leap year > assert. 0 11 0 -: 2000 2 1 age 1999 3 1 NB. event previous year after and > current before feb 29 in leap year > assert. 1 0 1 -: 1900 3 2 age 1899 3 1 NB. event previous year and current > after feb 28 in non leap year > assert. 1 0 2 -: 1900 3 1 age 1899 2 27 NB. event previous year and > current before feb 28 in non leap year > assert. 1 0 1 -: 1900 3 1 age 1899 2 28 NB. event previous year before and > current after feb 28 in non leap year > assert. 0 11 0 -: 1900 2 1 age 1899 3 1 NB. event previous year after and > current before feb 29 in non leap year > ) > > testdate '' > On Sep 23, 2014, at 9:58 AM, robert therriault <[email protected]> > wrote: > > > Arghhh! > > > > The challenges of an evolving test suite. :-) My guess is that I can > fix that using the same type of adjustment that I used for the month > result, but it will be a while before I get a chance to check it out, and > this puzzle has surprised me more than once! > > > > Thanks for catching that Joe. > > > > Cheers, bob > > > > On Sep 23, 2014, at 9:50 AM, Joe Bogner <[email protected]> wrote: > > > >> bob, is this right? > >> > >> 2014 1 1 age 2013 12 31 > >> > >> 1 0 1 > >> > >> > >> I would have expected 0 0 1 ? > >> > >> On Tue, Sep 23, 2014 at 12:44 PM, robert therriault < > [email protected]> > >> wrote: > >> > >>> Hi PA > >>> > >>> I think that Raul's isleap takes this into account and does make 2000 > the > >>> leap year that it should be. > >>> > >>> http://www.timeanddate.com/date/leapyear.html > >>> > >>> Cheers, bob > >>> > >>> On Sep 23, 2014, at 9:37 AM, PMA <[email protected]> wrote: > >>> > >>>> Just in case, 2000 (divisible by 400) isn't a leap > >>>> year either, though my Linux 'cal' claims it was. > >>>> > >>>> PA > >>>> > >>>> > >>>> Linda Alvord wrote: > >>>>> Don, You bailed me out of this little glitch! Linda i U > >>>>> > >>>>> -----Original Message----- > >>>>> From: [email protected] > >>>>> [mailto:[email protected]] On Behalf Of Don > >>> Kelly > >>>>> Sent: Monday, September 22, 2014 10:14 PM > >>>>> To: [email protected] > >>>>> Subject: Re: [Jprogramming] Weekend Puzzle - Age of Groundhog born > 2002 > >>> 2 2 > >>>>> > >>>>> Fortunately, the use of "leap" is valid as long as one doesn't go > back > >>>>> past 1901 or ahead past 2099. > >>>>> > >>>>> 1900 and 2100 aren't leap years (Fine tuning of the leap year > >>> calculation ). > >>>>> > >>>>> Don Kelly > >>>> ---------------------------------------------------------------------- > >>>> For information about J forums see > http://www.jsoftware.com/forums.htm > >>> > >>> ---------------------------------------------------------------------- > >>> For information about J forums see http://www.jsoftware.com/forums.htm > >>> > >> ---------------------------------------------------------------------- > >> For information about J forums see http://www.jsoftware.com/forums.htm > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
