[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: perl leap year function?

Since leap years fall within a specific pattern, I can't see why you would
have to hardcode the next few.

In psuedo-code, just have a function like:

function isLeapYear(year as int) as boolean
	if remainder(year div 4) = 0 then
		return true
	else return false

I realise this isnt the only condition (theres something fishy about years
divisible by 400 from memory) but it would do the trick.

Of course, hardcoding the next few will tide you over for what is most
likely enough time, im just a sucker for flexible code.

 Corey Popelier
 Dept. Of Commerce and Trade
 Perth, Western Australia

On Wed, 1 Sep 1999, Aaron Van Couwenberghe wrote:

> Just a question -
>   I need an algorithm that can match a number of days with any month. For
> this to be useful, I need a function that can tell me if it's a leap year
> this year.
> Is there one available in any of the perl modules? If not I could just
> hardcode the next few into my script...
> -- 
> ..Aaron Van Couwenberghe... ..vanco@sonic.net.. ..aaronv@debian.org....
> 	Berlin:			http://www.berlin-consortium.org
> 	Debian GNU/Linux:	http://www.debian.org
> There are three kinds of people in this world: those who can count and
> 	those who can't.
> -- 
> Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null

Reply to: