Calendar Functions (simpler leap year calculation)

Dick Dunn rcd at nbires.UUCP
Thu Sep 18 15:17:02 AEST 1986


In article <1193 at ttrdc.UUCP>, levy at ttrdc.UUCP (Daniel R. Levy) writes:
> In article <34 at vianet.UUCP>, devine at vianet.UUCP (Bob Devine) writes:
[example of leap-year test covering 4, 100, 400]
> >  While this works, it is overkill.  Unless you believe that your
> >code will make it to the year 2100, a simple test for divisibility
> >by 4 is sufficient...
> Butbutbut... whattabout code which deals with things that are of concern
> over more than a few years' scope, such as positions of the heavenly bodies?

Butbutbut...the argument to the procedure was an int year, apparently CE.
So if you're worrying about getting it absolutely correct, don't forget the
Gregorian correction!  Leap years are child's play next to that one.

No, really, look:  FIRST, decide the domain for the function.  THEN design
the function to work well in that domain.  IF someone tells you that the
function doesn't work for his problem (outside the domain of the function),
tell him that hammers don't work for sawing wood, either.
-- 
Dick Dunn    {hao,ucbvax,allegra,seismo}!nbires!rcd	(303)444-5710 x3086
   ...Are you making this up as you go along?



More information about the Comp.lang.c mailing list