Someone I know once calculated that there should be a 4000-year correction as well, to whit: there is an exception (flip parity) to the "divisible by 400" exception if the year is divisible by 4000.
However, this assumes that the year calculation is purely mathematical when in fact it is ultimately political. The J expression "m11" is nicely succinct and easily extendible if we wish to add this additional exception: m11=: 0: ~:/ .= 4 100 400"_ |/ ] m11_4k=: 0: ~:/ .= 4 100 400 4000"_ |/ ] m11 1900 1901 1999 2000 2003 2004 3600 3999 4000 4004 0 0 0 1 0 1 1 0 1 1 m11_4k 1900 1901 1999 2000 2003 2004 3600 3999 4000 4004 0 0 0 1 0 1 1 0 0 1 On 12/29/06, Björn Helgason <[EMAIL PROTECTED]> wrote:
Sorry forgot this was wrong 2000 was a leap year! "The short answer The rule for leap years is that all years divisable by 4 are leap years, except those years divisable by 100. The exception is that years divisible by 400 are leap years. This means that 1800 and 1900 were not leap years, but the year 2000 is a leap year." 2006/12/29, Björn Helgason <[EMAIL PROTECTED]>: > > \j601\system\examples\phrases\phrb14.ijs (1) > > NB. J Phrases Section 14B. Date & Time > > m11=: 0: ~:/ .= 4 100 400"_ |/ ] NB. > Is y a leap year? > > (m11 arg)#arg =: 1990+i.20 > 1992 1996 2000 2004 2008 > > NB. 2000 was not a leap year > > m11 2000 > 1 > m11 2001 > 0 > > > check_leap_year =: 3 : 0 > return=.0 > datea =. y > if.datea -: 4*>.datea%4 > do. > if. -.datea -: 100*>.datea%100 > do. > return =. 1 > else. > if. -.datea -: 400*>.datea%400 > do. > return=.1 > else. > return=.0 > end. > end. > end. > return > ) > > (check_leap_year "0 arg ) # arg=: 1990+i.20 > 1992 1996 2004 2008 > > > > PS: I wish a new year > > -- > Björn Helgason, Verkfræðingur > Fugl&Fiskur ehf, Þerneyjarsund 23, Box 127 > 801 Grímsnes ,t-póst: [EMAIL PROTECTED] > Skype: gosiminn, gsm: +3546985532 > Landslags og skrúðgarðagerð, gröfuþjónusta > http://groups.google.com/group/J-Programming > > > Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans > > góður kennari getur stigið á tær án þess að glansinn fari af skónum > /|_ .-----------------------------------. > ,' .\ / | Með léttri lund verður | > ,--' _,' | Dagurinn í dag | > / / | Enn betri en gærdagurinn | > ( -. | `-----------------------------------' > | ) | (\_ _/) > (`-. '--.) (='.'=) > `. )----' (")_(") -- Björn Helgason, Verkfræðingur Fugl&Fiskur ehf, Þerneyjarsund 23, Box 127 801 Grímsnes ,t-póst: [EMAIL PROTECTED] Skype: gosiminn, gsm: +3546985532 Landslags og skrúðgarðagerð, gröfuþjónusta http://groups.google.com/group/J-Programming Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans góður kennari getur stigið á tær án þess að glansinn fari af skónum /|_ .-----------------------------------. ,' .\ / | Með léttri lund verður | ,--' _,' | Dagurinn í dag | / / | Enn betri en gærdagurinn | ( -. | `-----------------------------------' | ) | (\_ _/) (`-. '--.) (='.'=) `. )----' (")_(") ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
-- Devon McCormick ^me^ at acm. org is my preferred e-mail ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
