Utils/US_Date.pm

filter: Statementstmt 100% 31 / 31 Branchbran 100% 2 / 2 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 89.3% 42 / 47 CC 4 SCAR 7.9
CC
4
Cov
95%
process
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Utils/Base.pm ↑ Summary Utils/Keys.pm »
1 package Petal::Utils::US_Date;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use base qw( Petal::Utils::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use constant name => 'us_date';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use constant aliases => qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 our $VERSION = ((require Petal::Utils), $Petal::Utils::VERSION)[1];
14 2 our $REVISION = (split(/ /, ' $Revision: 1.2 $ '))[2];
15  
16 4 ▶sub process {
Subroutine process: called CC=4 SCAR=13.9
Pod undocumented
17 4 my $class = shift;
18 4 my $hash = shift;
19 4 ▶ my $args = shift || confess( "'us_date' expects a variable (got nothing)!" );
Condition50%1/2
shift() || confess(q['us_date' expects a variable (got nothing)!])
l!l
40
MC/DC0%0/1
shift() || confess(q['us_date' expects a variable (got nothing)!])
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
20  
21 4 my ($year,$mon,$day);
22 4 my ($date, $sep) = $hash->fetch($args);
23 4 ▶ $sep ||= '/';
Condition50%1/2
$sep ||= "/"
l!l
04
MC/DC0%0/1
$sep ||= "/"
$sep
Truth table50%1/2
A
A= $sep
Aresult
11
00
24 4 ▶ if ($date =~ /[-|\/]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($date =~ m[[-|/]]) { } 2 2 4
25 2 ($year,$mon,$day) = split(/[-|\/]/, $date);
26 }
27 else {
28 2 ($year,$mon,$day) = $date =~ /(\d{4})(\d{2})(\d{2})/;
29 }
30  
31 4 return sprintf("%02d$sep%02d$sep%04d", $mon,$day,$year);
32 }
33  
34 2 1;
35  
36 __END__
« Utils/Base.pm ↑ Summary Utils/Keys.pm »