DaysInMonth.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 46 CC 6 SCAR 24.2
CC
6
Cov
0%
is_leap
20.0
days_in
12.0
BEGIN
2.0
CRAP 11.3
1 package Time::DaysInMonth;
2  
3 use Carp;
4  
5 require 5.008001;
6  
7 @ISA = qw(Exporter);
8 @EXPORT = qw(days_in is_leap);
9 @EXPORT_OK = qw(%mltable);
10  
11 use strict;
12  
13 use vars qw($VERSION %mltable);
14  
15 $VERSION = 2026.0330;
16  
17 CONFIG: {
18 %mltable = qw(
19 1 31
20 3 31
21 4 30
22 5 31
23 6 30
24 7 31
25 8 31
26 9 30
27 10 31
28 11 30
29 12 31);
30 }
31  
32 sub days_in
33 {
34 # Month is 1..12
35 my ($year, $month) = @_;
36 return $mltable{$month+0} unless $month == 2;
37 return 28 unless &is_leap($year);
38 return 29;
39 }
40  
41 sub is_leap
42 {
43 my ($year) = @_;
44 return 0 unless $year % 4 == 0;
45 return 1 unless $year % 100 == 0;
46 return 0 unless $year % 400 == 0;
47 return 1;
48 }
49  
50 1;
51  
52 __END__