File Coverage

blib/lib/Date/Indiction.pm
Criterion Covered Total %
statement 17 18 94.4
branch 8 10 80.0
condition 6 9 66.6
subroutine 7 7 100.0
pod 0 4 0.0
total 38 48 79.1


line stmt bran cond sub pod time code
1             package Date::Indiction;
2 1     1   529 use strict;
  1         2  
  1         22  
3 1     1   4 use warnings;
  1         1  
  1         267  
4              
5             require Exporter;
6             our @ISA = qw(Exporter);
7             our @EXPORT = qw(indiction);
8              
9             our $VERSION = '0.01';
10             our $SUB;
11             our $DEFAULT_SUB = 'byzantine';
12              
13             sub import {
14 1 50   1   9 $SUB = $_[1] ? \&{lc $_[1]} : \&$DEFAULT_SUB;
  0         0  
15 1         26 goto &Exporter::import;
16             }
17              
18             # Returns the indiction of the year using either &byzantine or
19             # &christian
20             sub indiction {
21 9     9 0 899 return $SUB->(@_);
22             }
23              
24             sub set_aera {
25 1     1 0 1 $SUB = \&{$_[0]};
  1         4  
26             }
27              
28             sub byzantine {
29 5     5 0 7 my ($year, $month) = @_;
30 5 50 66     19 $year +=1 if $month && ($month >= 9 || $month < 3);
      66        
31 5 100       23 $year % 15 || 15;
32             }
33              
34             sub christian {
35 4     4 0 5 my ($year, $month) = @_;
36 4 100 66     15 $year +=1 if $month && $month >= 9;
37 4 100       18 ($year+3) % 15 || 15;
38             }
39              
40             *AM = \&byzantine;
41             *AD = \&christian;
42              
43             1;
44             __END__