Re: 28 or 29 days?

new topic     » goto parent     » topic index » view thread      » older message » newer message

> Hi all,
>
> I need URGENTLY an algorithm to see is a given year is a leap year.
> Can any of you help me? I bet that in some old book it appears ;)

Here's a short routine that'll do that:

function leap_year (integer year)
  -- Returns true if year is a leap year, otherwise false.

    if year<1582 then
         if remainder(year,4)=0 then
             return 1
         else
             return 0
         end if
    else
        if remainder(year,400)=0 then
            return 1
        elsif remainder(year,100)=0 then
            return 0
        elsif remainder(year,4)=0 then
            return 1
        else
            return 0
        end if
    end if
end function

Regards,
               Michael Bolin

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu