in reply to How do I determine if a given year is a leap year?
Not my work, but a great example:
sub IsLeapYear { my $year = shift; return 0 if $year % 4; return 1 if $year % 100; return 0 if $year % 400; return 1; }
The IsLeapYear subroutine is called with a year number, like
IsLeapYear(2006);
The function returns a true value if the year number is a leap year, false otherwise.
Get the correct number of days in February for the given year:
my $days_in_February = IsLeapYear($year) ? 29 : 28;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Answer: How do I determine if a given year is a leap year?
by MidLifeXis (Monsignor) on Jan 10, 2011 at 14:45 UTC |