Re: Programming using 4GL
Posted in 1993
In <C51FKL.3oB@promdist.pds.com> bill@promdist.pds.com (Bill Foote) writes: >In article <1pq73oINN8pa@emory.mathcs.emory.edu> RUCHI%CFRVM.BITNET@uga.cc.uga.edu (Ruchi Patel) writes: >> >>Is there any way I can find out maximum days for the current month? >> >>e.g 4/5/93 - April has 30 days >> >And just to be difficult: >Does anyone know a solution that _wouldn't_ break for February of 2400? >(I'm pretty sure that we don't have leap year once every 400 years, and >that 2400 is the next leap year we skip... We _don't_ skip leap >year in 2000 (I think) because of a rule that says that we skip skipping >the leap year every 2000 years. These rules subject to change and the >gravitational effects of passing comets.) I haven't tested Informix's date routines, but the algorithm is slightly more complex than you describe: - Every 4 years (i.e., year is a multiple of 4) is a leap year, except - Every 100 years is NOT a leap year, except - Every 400 years IS a leap year. Thus 2000 and 2400 are leap years, but NOT 2100, 2200, 2300. Or 1900. Thus, unless you expect your software to stil be running in 2100, you can use the "every 4 years is a leap year" rule without fail. :-) If you want to *really* stress out a date package, test it on September, 1752. This is when the pope's date correction for past extra (100not400) leap years was taken from the calendar. Unix's 'cal 9 1752' gets it right: September 1752 S M Tu W Th F S 1 2 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 I believe other countries did this at other times, but I don't have the reference handy. -- Andrew Burt aburt@du.edu "But if he was dying he wouldn't bother to carve "Aaaaargh", he'd just say it."