| 1 | # $Header: /cvsroot/date-leapyear/lib/Date/Leapyear.pm,v 1.71 2002/08/30 00:00:25 rbowen Exp $ | ||||||||||
| 2 | package Date::Leapyear; | ||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 3 | ▶ | use Exporter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use vars qw(@ISA @EXPORT $VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 3 | @ISA = qw(Exporter); | |||||||||
| 8 | |||||||||||
| 9 | 3 | @EXPORT = qw( isleap ); | |||||||||
| 10 | 3 | $VERSION = ( qw'$Revision: 1.72 $' )[1]; | |||||||||
| 11 | |||||||||||
| 12 | =head1 NAME | ||||||||||
| 13 | |||||||||||
| 14 | Date::Leapyear - Is a particular year a leap year? | ||||||||||
| 15 | |||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||
| 17 | |||||||||||
| 18 | use Date::Leapyear; | ||||||||||
| 19 | if ( isleap(1945) ) { | ||||||||||
| 20 | ... | ||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||
| 24 | |||||||||||
| 25 | Date::Leapyear exports one function - isleap - which returns 1 or 0 if | ||||||||||
| 26 | a year is leap, or not, respectively. | ||||||||||
| 27 | |||||||||||
| 28 | =head1 isleap | ||||||||||
| 29 | |||||||||||
| 30 | $true = isleap( 2004 ); | ||||||||||
| 31 | |||||||||||
| 32 | Returns 1 in a leap year, 0 otherwise. | ||||||||||
| 33 | |||||||||||
| 34 | =cut | ||||||||||
| 35 | |||||||||||
| 36 | 761 | ▶ | sub isleap { | ||||||||
|
Subroutine
isleap: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 37 | 761 | my ($year) = @_; | |||||||||
| 38 | 761 | ▶ | return 1 if (( $year % 400 ) == 0 ); # 400's are leap | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 753 | ▶ | return 0 if (( $year % 100 ) == 0 ); # Other centuries are not | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 729 | ▶ | return 1 if (( $year % 4 ) == 0 ); # All other 4's are leap | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 5 | return 0; # Everything else is not | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 3 | 1; | |||||||||
| 45 | |||||||||||
| 46 | =head1 AUTHOR | ||||||||||
| 47 | |||||||||||
| 48 | Rich Bowen (rbowen@rcbowen.com) | ||||||||||
| 49 | |||||||||||
| 50 | =cut | ||||||||||
| 51 | |||||||||||