Calendar/Coptic.pm

filter: Statementstmt 55.3% 36 / 65 Branchbran 21.8% 7 / 32 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 41.1% 7 / 17 Podpod 40.0% 4 / 10 totaltotal 42.1% 56 / 133 CC 19 SCAR 21.8
CC
19
Cov
44%
new
15.2
full_date
12.0
long_date
12.0
CRAP 8.8
« Calendar/CopticEthiopic.pm ↑ Summary Languages.pm »
1 package DateTime::Calendar::Coptic;
2 1 ▶use base qw( DateTime::Calendar::CopticEthiopic );
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 BEGIN
5 1 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
9 $VERSION
10 $n
11 1 );
12  
13 1 $VERSION = "0.05";
14  
15 1 require DateTime::Calendar::Coptic::Languages;
16  
17 1 require Convert::Number::Coptic;
18 1 $n = new Convert::Number::Coptic;
19  
20 }
21  
22 sub new
23 2 ▶{
Subroutine new: called CC=10 SCAR=27.2
Pod documented
24 2 my $class = shift;
25 2 ▶my %args = @_ if ($#_);
Branch: 1 branch
BranchTrueFalseTotal
if $#_ 2 0 2
26 2 my $language = "cop";
27  
28 2 my $self;
29  
30 2 ▶ if ( $args{language} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"language"}) 0 2 2
31 0 $language = $args{language};
32 0 delete ( $args{language} );
33 }
34 2 ▶ if ( $args{calscale} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"calscale"}) 1 1 2
35 1 ▶ if ( $args{calscale} =~ /gregorian/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($args{'calscale'} =~ /gregorian/i) { } 1 0 1
elsif ($args{'calscale'} =~ /copticpic/i) { } 0 0 0
36 #
37 # We have been given dates in the Gregorian system
38 # so we must convert into Coptic
39 #
40 1 my $dt = {}; bless $dt, $class;
41 1 ▶ if ( $args{day} && $args{month} && $args{year} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'day'} and $args{'month'} and $args{'year'}) { } 1 0 1
Condition33%2/6
$args{"day"} and $args{"month"} and $args{"year"}
!ll&&!rl&&r
001
$args{"day"} and $args{"month"}
!ll&&!rl&&r
001
MC/DC0%0/3
$args{"day"} and $args{"month"} and $args{"year"}
$args{"day"} $args{"month"} $args{"year"}
Truth table25%1/4
A and B and C
A= $args{"day"}B= $args{"month"}C= $args{"year"}
ABCresult
0XX0
10X0
1100
1111
42 ( $args{day}, $args{month}, $args{year} )
43 1 = $dt->fromGregorian ( $args{day}, $args{month}, $args{year} );
44 }
45 else {
46 0 die ( "Useless Gregorian context, no date args passed.\n" );
47 }
48 }
49 elsif ( $args{calscale} =~ /copticpic/i ) {
50 0 $args{year} -= 276;
51 }
52 1 delete ( $args{calscale} );
53 }
54  
55 2 $self = new DateTime ( %args );
56  
57 2 ▶ if ( ref($language) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $language) { } 0 2 2
58 0 $self->{language} = $language;
59 }
60 else {
61 # print "Loading $language\n";
62 2 $self->{language} = DateTime::Calendar::Coptic::Languages->new ( language => $language );
63 }
64  
65 2 my $blessing = bless ( $self, $class );
66  
67 2 $self->{rd} = $self->_EthiopicToAbsolute;
68  
69 2 $blessing;
70 }
71  
72 sub from_object
73 0 ▶{
Subroutine from_object: not called CC=2 SCAR=17.9
Pod documented
74 0 my ( $class ) = shift;
75 0 my %args = validate( @_,
76 {
77 object => {
78 type => OBJECT,
79 can => 'utc_rd_values',
80 },
81 },
82 );
83  
84 0 my $object = $args{ object }->clone();
85 0 ▶ $object->set_time_zone( 'floating' ) if $object->can( 'set_time_zone' );
Branch: 1 branch
BranchTrueFalseTotal
if $object->can("set_time_zone") 0 0 0
86  
87 0 my ( $rd, $rd_secs ) = $object->utc_rd_values();
88  
89 0 my $self = bless( { rd => $rd, rd_secs => $rd_secs }, $class );
90  
91 0 $self;
92 }
93  
94  
95 sub epoch
96 6 ▶{
Subroutine epoch: called CC=1 SCAR=0.0
Pod documented
97 6 103605;
98 }
99  
100 sub utc_rd_values
101 0 ▶{
Subroutine utc_rd_values: not called CC=2 SCAR=17.9
Pod documented
102 0 my ($self) = @_;
103  
104 0 ▶ ( $self->{rd}, $self->{rd_secs} || 0 );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"rd_secs"} or 0 0 0 0
105 }
106  
107  
108 #
109 # calscale and toGregorian and are methods I recommend every non-Gregorian
110 # based DateTime package provide to identify itself and to convert the
111 # calendar system it handles into a normalized form.
112 #
113 sub calscale
114 0 ▶{
Subroutine calscale: not called CC=1 SCAR=6.9
Pod undocumented
115 0 "coptic";
116 }
117  
118  
119 sub _sep
120 0 ▶{
Subroutine _sep: not called CC=1 SCAR=6.9
121 0 ", ";
122 }
123  
124  
125 sub _daysep
126 0 ▶{
Subroutine _daysep: not called CC=1 SCAR=6.9
127 0 " exoou "
128 }
129  
130  
131 sub ad
132 0 ▶{
Subroutine ad: not called CC=1 SCAR=6.9
Pod undocumented
133 0 "AD"
134 }
135  
136  
137 sub full_date
138 0 ▶{
Subroutine full_date: not called CC=3 SCAR=24.8
Pod undocumented
139 0 my ($self) = shift;
140  
141 (@_)
142 ?
143 $self->day_name.$self->_sep.$self->month_name." ".$n->convert($self->day).$self->_daysep.$n->convert($self->year)." ".$self->ad
144 :
145 ( $self->{_trans} )
146 0 ▶ ?
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 0 0 0
$self->{'_trans'} ? : 0 0 0
147 $self->day_name(@_).$self->_sep.$self->month_name(@_)." ".$self->day.$self->_daysep.$self->year." ".$self->ad(@_)
148 :
149 $self->day_name.$self->_sep.$self->month_name." ".$self->day.$self->_daysep.$n->convert($self->year)." ".$self->ad
150 ;
151 }
152  
153  
154 sub long_date
155 0 ▶{
Subroutine long_date: not called CC=3 SCAR=24.8
Pod undocumented
156 0 my ($self) = shift;
157  
158 (@_)
159 ?
160 $n->convert($self->day)."-".$self->month_name."-".$n->convert($self->year)
161 :
162 ( $self->{_trans} )
163 0 ▶ ?
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 0 0 0
$self->{'_trans'} ? : 0 0 0
164 $self->day."-".$self->month_name(@_)."-".$self->year
165 :
166 $self->day."-".$self->month_name."-".$n->convert($self->year)
167 ;
168 }
169  
170  
171 sub medium_date
172 0 ▶{
Subroutine medium_date: not called CC=3 SCAR=24.8
Pod undocumented
173 0 my ($self) = @_;
174
175 0 my $year = $self->year;
176 0 $year =~ s/^\d\d//;
177  
178 ($#_)
179 ?
180 $self->day."-".$self->month_name."-".$n->convert($year)
181 :
182 ( $self->{_trans} )
183 0 ▶ ?
Branch: 2 branches
BranchTrueFalseTotal
$#_ ? : 0 0 0
$self->{'_trans'} ? : 0 0 0
184 $self->day."-".$self->month_name(@_)."-".$year
185 :
186 $n->convert($self->day)."-".$self->month_name."-".$n->convert($year)
187 ;
188 }
189  
190  
191 sub useTranscription
192 0 ▶{
Subroutine useTranscription: not called CC=2 SCAR=17.9
Pod undocumented
193 0 my $self = shift;
194  
195 0 ▶ $self->{_trans} = shift if (@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
196  
197 0 $self->{_trans};
198 }
199  
200  
201 #########################################################
202 # Do not change this, Do not put anything below this.
203 # File must return "true" value at termination
204 1 1;
205 ##########################################################
206  
207 __END__
« Calendar/CopticEthiopic.pm ↑ Summary Languages.pm »