D.pm

filter: Statementstmt 15.4% 39 / 253 Branchbran 0.0% 0 / 150 Conditioncond 0.0% 0 / 60 MC/DCmcdc 0.0% 0 / 40 Subroutinesub 25.0% 7 / 28 Podpod 100% 13 / 13 totaltotal 10.8% 59 / 544 CC 96 SCAR 56.8
CC
96
Cov
8%
to_array
870.0
to_string
462.0
__ANON__
30.0
CRAP 294.0
« P.pm ↑ Summary F.pm »
1 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Time::D;
4 8 $Time::D::VERSION = '0.024';
5 # ABSTRACT: Differentiate between two times.
6  
7 9 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=0.6
8 0 ▶ '""' => sub { shift->to_string(2); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
9 0 ▶ bool => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
10 9 fallback => 1,
11 9 );
12  
13 9 ▶use Carp qw/ croak /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 9 ▶use Function::Parameters qw/ :strict /;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 9 ▶use Time::C;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 8 ▶use Time::C::Sentinel;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19  
20 0 ▶method new ($c: $base, $comp = $base) {
Subroutine new: not called CC=4 SCAR=30.0
Pod documented
Branch: 3 branches
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for method new (expected 2, got ' . @_ . ')') 0 0 0
@_ > 3 and Function::Parameters::_croak('Too many arguments for method new (expected 3, got ' . @_ . ')') 0 0 0
@_ < 2 and $comp = $base 0 0 0
21 0 bless { base => $base, comp => $comp }, $c;
22 8 }
23  
24 0 ▶method _setter ($d: $key, $new) {
Subroutine _setter: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
@_ < 3 and Function::Parameters::_croak('Too few arguments for method _setter (expected 3, got ' . @_ . ')') 0 0 0
@_ > 3 and Function::Parameters::_croak('Too many arguments for method _setter (expected 3, got ' . @_ . ')') 0 0 0
25 0 ▶ return sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
26 0 $d->{$key} = $_[0];
27 0 ▶ return $d if defined $new;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new 0 0 0
28 0 return $_[0];
29 0 };
30 8 }
31  
32 0 ▶method _computed_setter ($d: $key, $new) {
Subroutine _computed_setter: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
@_ < 3 and Function::Parameters::_croak('Too few arguments for method _computed_setter (expected 3, got ' . @_ . ')') 0 0 0
@_ > 3 and Function::Parameters::_croak('Too many arguments for method _computed_setter (expected 3, got ' . @_ . ')') 0 0 0
33 0 my %diff;
34 0 @diff{qw/ sign year month week day hour minute second /} = $d->to_array();
35  
36 0 my $val = $diff{$key};
37  
38 0 my $ct = Time::C->gmtime($d->comp);
39 0 ▶ return $val, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
40 0 ▶ if ($diff{sign} eq '-') {
Branch: 1 branch
BranchTrueFalseTotal
if ($diff{'sign'} eq '-') { } 0 0 0
41 0 $ct->$key -= $_[0] - $val;
42 } else {
43 0 $ct->$key -= $val - $_[0];
44 }
45 0 $d->comp = $ct->epoch;
46  
47 0 ▶ return $d if defined $new;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new 0 0 0
48 0 return $_[0];
49 0 };
50 8 }
51  
52  
53  
54 0 ▶method base ($d: $new_base = undef) :lvalue {
Subroutine base: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method base (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method base (expected 2, got ' . @_ . ')') 0 0 0
55 0 my $setter = $d->_setter('base', $new_base);
56  
57 0 ▶ return $setter->($new_base) if defined $new_base;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_base 0 0 0
58  
59 0 sentinel value => $d->{base}, set => $setter;
60 8 }
61  
62  
63 0 ▶method comp ($d: $new_comp = undef) :lvalue {
Subroutine comp: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method comp (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method comp (expected 2, got ' . @_ . ')') 0 0 0
64 0 my $setter = $d->_setter('comp', $new_comp);
65  
66 0 ▶ return $setter->($new_comp) if defined $new_comp;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_comp 0 0 0
67  
68 0 sentinel value => $d->{comp}, set => $setter;
69 8 }
70  
71  
72 0 ▶method sign ($d: $new_sign = undef) :lvalue {
Subroutine sign: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method sign (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method sign (expected 2, got ' . @_ . ')') 0 0 0
73 0 my %diff;
74 0 @diff{qw/ sign year month week day hour minute second /} = $d->to_array();
75  
76 0 my $sign = $diff{sign};
77  
78 0 my $ct = Time::C->gmtime($d->comp);
79  
80 0 ▶ my $setter = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
81 0 ▶ if ($_[0] ne '+' and $_[0] ne '-') { croak "Can't set a sign other than '+' or '-'."; }
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] ne "+" and $_[0] ne "-") 0 0 0
Condition0%0/3
$_[0] ne "+" and $_[0] ne "-"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] ne "+" and $_[0] ne "-"
$_[0] ne "+" $_[0] ne "-"
Truth table0%0/3
A and B
A= $_[0] ne "+"B= $_[0] ne "-"
ABresult
0X0
100
111
82  
83 0 ▶ if ($_[0] ne $sign) { $d->comp += 2*($d->base-$d->comp); }
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] ne $sign) 0 0 0
84  
85 0 ▶ return $d if defined $new_sign;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_sign 0 0 0
86 0 return $_[0];
87 0 };
88  
89 0 ▶ return $setter->($new_sign) if defined $new_sign;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_sign 0 0 0
90  
91 0 sentinel value => $sign, set => $setter;
92 8 }
93  
94  
95 0 ▶method years ($d: $new_years = undef) :lvalue {
Subroutine years: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method years (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method years (expected 2, got ' . @_ . ')') 0 0 0
96 0 my ($years, $setter) = $d->_computed_setter('year', $new_years);
97  
98 0 ▶ return $setter->($new_years) if defined $new_years;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_years 0 0 0
99  
100 0 sentinel value => $years, set => $setter;
101 8 }
102  
103  
104 0 ▶method months ($d: $new_months = undef) :lvalue {
Subroutine months: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method months (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method months (expected 2, got ' . @_ . ')') 0 0 0
105 0 my ($months, $setter) = $d->_computed_setter('month', $new_months);
106  
107 0 ▶ return $setter->($new_months) if defined $new_months;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_months 0 0 0
108  
109 0 sentinel value => $months, set => $setter;
110 8 }
111  
112  
113 0 ▶method weeks ($d: $new_weeks = undef) :lvalue {
Subroutine weeks: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method weeks (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method weeks (expected 2, got ' . @_ . ')') 0 0 0
114 0 my ($weeks, $setter) = $d->_computed_setter('week', $new_weeks);
115  
116 0 ▶ return $setter->($new_weeks) if defined $new_weeks;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_weeks 0 0 0
117  
118 0 sentinel value => $weeks, set => $setter;
119 8 }
120  
121  
122 0 ▶method days ($d: $new_days = undef) :lvalue {
Subroutine days: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method days (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method days (expected 2, got ' . @_ . ')') 0 0 0
123 0 my ($days, $setter) = $d->_computed_setter('day', $new_days);
124  
125 0 ▶ return $setter->($new_days) if defined $new_days;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_days 0 0 0
126  
127 0 sentinel value => $days, set => $setter;
128 8 }
129  
130  
131 0 ▶method hours ($d: $new_hours = undef) :lvalue {
Subroutine hours: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method hours (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method hours (expected 2, got ' . @_ . ')') 0 0 0
132 0 my ($hours, $setter) = $d->_computed_setter('hour', $new_hours);
133  
134 0 ▶ return $setter->($new_hours) if defined $new_hours;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_hours 0 0 0
135  
136 0 sentinel value => $hours, set => $setter;
137 8 }
138  
139  
140 0 ▶method minutes ($d: $new_minutes = undef) :lvalue {
Subroutine minutes: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method minutes (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method minutes (expected 2, got ' . @_ . ')') 0 0 0
141 0 my ($minutes, $setter) = $d->_computed_setter('minute', $new_minutes);
142  
143 0 ▶ return $setter->($new_minutes) if defined $new_minutes;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_minutes 0 0 0
144  
145 0 sentinel value => $minutes, set => $setter;
146 8 }
147  
148  
149 0 ▶method seconds ($d: $new_seconds = undef) :lvalue {
Subroutine seconds: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method seconds (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method seconds (expected 2, got ' . @_ . ')') 0 0 0
150 0 my ($seconds, $setter) = $d->_computed_setter('second', $new_seconds);
151  
152 0 ▶ return $setter->($new_seconds) if defined $new_seconds;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_seconds 0 0 0
153  
154 0 sentinel value => $seconds, set => $setter;
155 8 }
156  
157  
158  
159 0 ▶method to_array ($d:) {
Subroutine to_array: not called CC=29 SCAR=67.7
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method to_array (expected 1, got ' . @_ . ')') 0 0 0
@_ > 1 and Function::Parameters::_croak('Too many arguments for method to_array (expected 1, got ' . @_ . ')') 0 0 0
160 0 my $bt = Time::C->gmtime($d->base);
161 0 my $ct = Time::C->gmtime($d->comp);
162  
163 0 ▶ my $sign = $d->base > $d->comp ? '-' : '+';
Branch: 1 branch
BranchTrueFalseTotal
$d->base > $d->comp ? : 0 0 0
164  
165 0 my $years = $bt->tm->delta_years($ct->tm);
166 0 $ct->year -= $years;
167 0 ▶ if ($sign eq '+' and $bt->epoch > $ct->epoch) { $years--; $ct->year++; }
Branch: 2 branches
BranchTrueFalseTotal
if ($sign eq '+' and $bt->epoch > $ct->epoch) { } 0 0 0
elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { } 0 0 0
Condition0%0/3
$sign eq "+" and $bt->epoch > $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "+" and $bt->epoch > $ct->epoch
$sign eq "+" $bt->epoch > $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "+"B= $bt->epoch > $ct->epoch
ABresult
0X0
100
111
168 0 ▶ elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { $years++; $ct->year--; }
Condition0%0/3
$sign eq "-" and $bt->epoch < $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "-" and $bt->epoch < $ct->epoch
$sign eq "-" $bt->epoch < $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "-"B= $bt->epoch < $ct->epoch
ABresult
0X0
100
111
169  
170 0 my $months = $bt->tm->delta_months($ct->tm);
171 0 $ct->month -= $months;
172 0 ▶ if ($sign eq '+' and $bt->epoch > $ct->epoch) { $months--; $ct->month++; }
Branch: 2 branches
BranchTrueFalseTotal
if ($sign eq '+' and $bt->epoch > $ct->epoch) { } 0 0 0
elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { } 0 0 0
Condition0%0/3
$sign eq "+" and $bt->epoch > $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "+" and $bt->epoch > $ct->epoch
$sign eq "+" $bt->epoch > $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "+"B= $bt->epoch > $ct->epoch
ABresult
0X0
100
111
173 0 ▶ elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { $months++; $ct->month--; }
Condition0%0/3
$sign eq "-" and $bt->epoch < $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "-" and $bt->epoch < $ct->epoch
$sign eq "-" $bt->epoch < $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "-"B= $bt->epoch < $ct->epoch
ABresult
0X0
100
111
174  
175 0 my $weeks = $bt->tm->delta_weeks($ct->tm);
176 0 $ct->week -= $weeks;
177 0 ▶ if ($sign eq '+' and $bt->epoch > $ct->epoch) { $weeks--; $ct->week++; }
Branch: 2 branches
BranchTrueFalseTotal
if ($sign eq '+' and $bt->epoch > $ct->epoch) { } 0 0 0
elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { } 0 0 0
Condition0%0/3
$sign eq "+" and $bt->epoch > $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "+" and $bt->epoch > $ct->epoch
$sign eq "+" $bt->epoch > $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "+"B= $bt->epoch > $ct->epoch
ABresult
0X0
100
111
178 0 ▶ elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { $weeks++; $ct->week--; }
Condition0%0/3
$sign eq "-" and $bt->epoch < $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "-" and $bt->epoch < $ct->epoch
$sign eq "-" $bt->epoch < $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "-"B= $bt->epoch < $ct->epoch
ABresult
0X0
100
111
179  
180 0 my $days = $bt->tm->delta_days($ct->tm);
181 0 $ct->day -= $days;
182 0 ▶ if ($sign eq '+' and $bt->epoch > $ct->epoch) { $days--; $ct->day++; }
Branch: 2 branches
BranchTrueFalseTotal
if ($sign eq '+' and $bt->epoch > $ct->epoch) { } 0 0 0
elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { } 0 0 0
Condition0%0/3
$sign eq "+" and $bt->epoch > $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "+" and $bt->epoch > $ct->epoch
$sign eq "+" $bt->epoch > $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "+"B= $bt->epoch > $ct->epoch
ABresult
0X0
100
111
183 0 ▶ elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { $days++; $ct->day--; }
Condition0%0/3
$sign eq "-" and $bt->epoch < $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "-" and $bt->epoch < $ct->epoch
$sign eq "-" $bt->epoch < $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "-"B= $bt->epoch < $ct->epoch
ABresult
0X0
100
111
184  
185 0 my $hours = $bt->tm->delta_hours($ct->tm);
186 0 $ct->hour -= $hours;
187 0 ▶ if ($sign eq '+' and $bt->epoch > $ct->epoch) { $hours--; $ct->hour++; }
Branch: 2 branches
BranchTrueFalseTotal
if ($sign eq '+' and $bt->epoch > $ct->epoch) { } 0 0 0
elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { } 0 0 0
Condition0%0/3
$sign eq "+" and $bt->epoch > $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "+" and $bt->epoch > $ct->epoch
$sign eq "+" $bt->epoch > $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "+"B= $bt->epoch > $ct->epoch
ABresult
0X0
100
111
188 0 ▶ elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { $hours++; $ct->hour--; }
Condition0%0/3
$sign eq "-" and $bt->epoch < $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "-" and $bt->epoch < $ct->epoch
$sign eq "-" $bt->epoch < $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "-"B= $bt->epoch < $ct->epoch
ABresult
0X0
100
111
189  
190 0 my $minutes = $bt->tm->delta_minutes($ct->tm);
191 0 $ct->minute -= $minutes;
192 0 ▶ if ($sign eq '+' and $bt->epoch > $ct->epoch) { $minutes--; $ct->minute++; }
Branch: 2 branches
BranchTrueFalseTotal
if ($sign eq '+' and $bt->epoch > $ct->epoch) { } 0 0 0
elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { } 0 0 0
Condition0%0/3
$sign eq "+" and $bt->epoch > $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "+" and $bt->epoch > $ct->epoch
$sign eq "+" $bt->epoch > $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "+"B= $bt->epoch > $ct->epoch
ABresult
0X0
100
111
193 0 ▶ elsif ($sign eq '-' and $bt->epoch < $ct->epoch) { $minutes++; $ct->minute--; }
Condition0%0/3
$sign eq "-" and $bt->epoch < $ct->epoch
!ll&&!rl&&r
000
MC/DC0%0/2
$sign eq "-" and $bt->epoch < $ct->epoch
$sign eq "-" $bt->epoch < $ct->epoch
Truth table0%0/3
A and B
A= $sign eq "-"B= $bt->epoch < $ct->epoch
ABresult
0X0
100
111
194  
195 0 my $seconds = $bt->tm->delta_seconds($ct->tm);
196  
197 0 ▶ if ($sign eq '-') {
Branch: 1 branch
BranchTrueFalseTotal
if ($sign eq "-") 0 0 0
198 0 ($years, $months, $weeks, $days, $hours, $minutes, $seconds) =
199 (-$years, -$months, -$weeks, -$days, -$hours, -$minutes, -$seconds);
200 }
201  
202 0 return $sign, $years, $months, $weeks, $days, $hours, $minutes, $seconds;
203 8 }
204  
205 0 ▶fun _plural ($num, $sing, $plur) { sprintf "%s %s", $num, $num == 1 ? $sing : $plur; }
Subroutine _plural: not called CC=4 SCAR=27.9
Branch: 3 branches
BranchTrueFalseTotal
@_ < 3 and Function::Parameters::_croak('Too few arguments for fun _plural (expected 3, got ' . @_ . ')') 0 0 0
@_ > 3 and Function::Parameters::_croak('Too many arguments for fun _plural (expected 3, got ' . @_ . ')') 0 0 0
$num == 1 ? : 0 0 0
206  
207  
208 0 ▶method to_string ($d: $precision = 7) {
Subroutine to_string: not called CC=21 SCAR=61.4
Pod documented
Branch: 3 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method to_string (expected 1, got ' . @_ . ')') 0 0 0
@_ > 2 and Function::Parameters::_croak('Too many arguments for method to_string (expected 2, got ' . @_ . ')') 0 0 0
@_ < 1 and $precision = 7 0 0 0
209 0 my ($sign, $years, $months, $weeks, $days, $hours, $minutes, $seconds) =
210 $d->to_array();
211  
212 0 my @out;
213  
214 0 ▶ if ($precision > 0 and $years) { $precision--; push @out, _plural($years, 'year', 'years'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($precision > 0 and $years) 0 0 0
Condition0%0/3
$precision > 0 and $years
!ll&&!rl&&r
000
MC/DC0%0/2
$precision > 0 and $years
$precision > 0 $years
Truth table0%0/3
A and B
A= $precision > 0B= $years
ABresult
0X0
100
111
215 0 ▶ if ($precision > 0 and $months) { $precision--; push @out, _plural($months, 'month', 'months'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($precision > 0 and $months) 0 0 0
Condition0%0/3
$precision > 0 and $months
!ll&&!rl&&r
000
MC/DC0%0/2
$precision > 0 and $months
$precision > 0 $months
Truth table0%0/3
A and B
A= $precision > 0B= $months
ABresult
0X0
100
111
216 0 ▶ if ($precision > 0 and $weeks) { $precision--; push @out, _plural($weeks, 'week', 'weeks'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($precision > 0 and $weeks) 0 0 0
Condition0%0/3
$precision > 0 and $weeks
!ll&&!rl&&r
000
MC/DC0%0/2
$precision > 0 and $weeks
$precision > 0 $weeks
Truth table0%0/3
A and B
A= $precision > 0B= $weeks
ABresult
0X0
100
111
217 0 ▶ if ($precision > 0 and $days) { $precision--; push @out, _plural($days, 'day', 'days'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($precision > 0 and $days) 0 0 0
Condition0%0/3
$precision > 0 and $days
!ll&&!rl&&r
000
MC/DC0%0/2
$precision > 0 and $days
$precision > 0 $days
Truth table0%0/3
A and B
A= $precision > 0B= $days
ABresult
0X0
100
111
218 0 ▶ if ($precision > 0 and $hours) { $precision--; push @out, _plural($hours, 'hour', 'hours'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($precision > 0 and $hours) 0 0 0
Condition0%0/3
$precision > 0 and $hours
!ll&&!rl&&r
000
MC/DC0%0/2
$precision > 0 and $hours
$precision > 0 $hours
Truth table0%0/3
A and B
A= $precision > 0B= $hours
ABresult
0X0
100
111
219 0 ▶ if ($precision > 0 and $minutes) { $precision--; push @out, _plural($minutes, 'minute', 'minutes'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($precision > 0 and $minutes) 0 0 0
Condition0%0/3
$precision > 0 and $minutes
!ll&&!rl&&r
000
MC/DC0%0/2
$precision > 0 and $minutes
$precision > 0 $minutes
Truth table0%0/3
A and B
A= $precision > 0B= $minutes
ABresult
0X0
100
111
220 0 ▶ if ($precision > 0 and $seconds) { $precision--; push @out, _plural($seconds, 'second', 'seconds'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($precision > 0 and $seconds) 0 0 0
Condition0%0/3
$precision > 0 and $seconds
!ll&&!rl&&r
000
MC/DC0%0/2
$precision > 0 and $seconds
$precision > 0 $seconds
Truth table0%0/3
A and B
A= $precision > 0B= $seconds
ABresult
0X0
100
111
221  
222 0 ▶ return "now" unless @out;
Branch: 1 branch
BranchTrueFalseTotal
unless @out 0 0 0
223  
224 0 ▶ if (@out > 1) { $out[-1] = "and $out[-1]"; }
Branch: 1 branch
BranchTrueFalseTotal
if (@out > 1) 0 0 0
225  
226 0 my $pretty = join ", ", @out;
227  
228 0 ▶ return sprintf $sign eq '+' ? "in %s" : "%s ago", $pretty;
Branch: 1 branch
BranchTrueFalseTotal
$sign eq '+' ? : 0 0 0
229 8 }
230  
231 8 1;
232  
233 __END__
« P.pm ↑ Summary F.pm »