line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
3
|
|
83057
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
101
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
14
|
use Exporter; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
118
|
|
6
|
3
|
|
|
3
|
|
15
|
use vars qw(@ISA @EXPORT $VERSION); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
433
|
|
7
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@EXPORT = qw( isleap ); |
10
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
sub isleap { |
37
|
761
|
|
|
761
|
0
|
406365
|
my ($year) = @_; |
38
|
761
|
100
|
|
|
|
2155
|
return 1 if (( $year % 400 ) == 0 ); # 400's are leap |
39
|
753
|
100
|
|
|
|
1499
|
return 0 if (( $year % 100 ) == 0 ); # Other centuries are not |
40
|
729
|
100
|
|
|
|
4278
|
return 1 if (( $year % 4 ) == 0 ); # All other 4's are leap |
41
|
5
|
|
|
|
|
20
|
return 0; # Everything else is not |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 AUTHOR |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Rich Bowen (rbowen@rcbowen.com) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|