# Re: perl leap year function?

*To*: Corey Popelier <corey@aceonline.com.au>
*Cc*: Aaron Van Couwenberghe <vanco@sonic.net>, debian-user@lists.debian.org
*Subject*: Re: perl leap year function?
*From*: Matthias Murra <Matt.Murra@gmx.de>
*Date*: Wed, 01 Sep 1999 11:27:26 +0200
*Message-id*: <3.0.3.32.19990901112726.04945e10@ganymed>
*In-reply-to*: <Pine.LNX.4.10.9909011648360.12483-100000@shell.aceonline.c om.au>
*References*: <19990901005541.F2668@localhost>

>function isLeapYear(year as int) as boolean
> if remainder(year div 4) = 0 then
> return true
> else return false
>end
>
>I realise this isnt the only condition (theres something fishy about years
>divisible by 400 from memory) but it would do the trick.
The "fishy" part is that years divisible by 100 aren't leap years,
whereas those divisible by 400 are. So 1700, 1800 and 1900 weren't
leap years, but Y2K will be.
>Of course, hardcoding the next few will tide you over for what is most
>likely enough time, im just a sucker for flexible code.
In that case, I suggest enhancing the above pseudo code as follows: :-)
function isLeapYear(year as int) as boolean
if ((remainder(year div 400) = 0) or (remainder(year div 100) <> 0 and
remainder(year div 4) = 0)) then
return true
else return false
end
Greets,
Matt

**Reply to:**