blib/lib/DateTime/Format/PGN.pm

filter: Statementstmt 71.4% 55 / 77 Branchbran 55.9% 47 / 84 Conditioncond 30.8% 38 / 123 MC/DCmcdc 19.3% 12 / 62 Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 45.8% 164 / 358 CC 84 SCAR 68.5
CC
84
Cov
49%
parse_datetime
1140.3
__ANON__
4.1
__ANON__
4.1
CRAP 942.5
↑ Summary
1 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package DateTime::Format::PGN;
5 # ABSTRACT: a Perl module for parsing and formatting date fields in chess game databases in PGN format
6  
7 5 our $VERSION = '1.02';
8  
9 5 ▶use DateTime::Incomplete 0.08;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Params::Validate 1.23 qw( validate BOOLEAN );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 6 ▶sub new {
Subroutine new: called CC=2 SCAR=8.1
Pod documented
14 6 my( $class ) = shift;
15  
16 my %args = validate( @_,
17 {
18 fix_errors => {
19 type => BOOLEAN,
20 default => 0,
21 callbacks => {
22 'is 0, 1, or undef' =>
23 3 ▶ sub { ! defined( $_[0] ) || $_[0] == 0 || $_[0] == 1 },
Subroutine __ANON__: called CC=3 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
not defined $_[0] or $_[0] == 0 or $_[0] == 1 0 3 3
Condition33%1/3
not defined $_[0] or $_[0] == 0
l!l&&r!l&&!r
003
MC/DC0%0/2
not defined $_[0] or $_[0] == 0
not defined $_[0] $_[0] == 0
Truth table33%1/3
not(A) or B
A= not defined $_[0]B= $_[0] == 0
ABresult
1X1
011
000
24 },
25 },
26 use_incomplete => {
27 type => BOOLEAN,
28 default => 0,
29 callbacks => {
30 'is 0, 1, or undef' =>
31 4 ▶ sub { ! defined( $_[0] ) || $_[0] == 0 || $_[0] == 1 },
Subroutine __ANON__: called CC=3 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
not defined $_[0] or $_[0] == 0 or $_[0] == 1 0 4 4
Condition33%1/3
not defined $_[0] or $_[0] == 0
l!l&&r!l&&!r
004
MC/DC0%0/2
not defined $_[0] or $_[0] == 0
not defined $_[0] $_[0] == 0
Truth table33%1/3
not(A) or B
A= not defined $_[0]B= $_[0] == 0
ABresult
1X1
011
000
32 },
33 },
34 }
35 6 );
36  
37 6 ▶ $class = ref( $class ) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
060
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
38  
39 6 my $self = bless( \%args, $class );
40  
41 6 return( $self );
42 }
43  
44  
45  
46 42 ▶sub parse_datetime {
Subroutine parse_datetime: called CC=76 SCAR=70.4
Pod documented
47 42 my ( $self, $date ) = @_;
48 42 my @matches = ( '????', '??', '??' );
49
50 42 ▶ if ($date =~ m/^(\?{4}|[1-2]\d{3})\.(\?{2}|0[1-9]|1[0-2])\.(\?{2}|0[1-9]|[1-2]\d|3[0-1])$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($date =~ /^(\?{4}|[1-2]\d{3})\.(\?{2}|0[1-9]|1[0-2])\.(\?{2}|0[1-9]|[1-2]\d|3[0-1])$/) { } 17 25 42
51
52 17 @matches = ( $1,$2,$3 );
53 }
54 else {
55
56 # We can try to fix frequently occuring faults.
57 25 ▶ if ($self->{ fix_errors }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"fix_errors"}) 24 1 25
58
59 # if we find a year, we can try to parse the wrong date.
60 24 ▶ if ($date =~ /(\A|\D)([1-2]\d{3})(\D|\Z)/ && $2 > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($date =~ /(\A|\D)([1-2]\d{3})(\D|\Z)/ and $2 > 0) 24 0 24
Condition33%1/3
$date =~ /(\A|\D)([1-2]\d{3})(\D|\Z)/ and $2 > 0
!ll&&!rl&&r
0024
MC/DC0%0/2
$date =~ /(\A|\D)([1-2]\d{3})(\D|\Z)/ and $2 > 0
$date =~ /(\A|\D)([1-2]\d{3})(\D|\Z)/ $2 > 0
Truth table33%1/3
A and B
A= $date =~ /(\A|\D)([1-2]\d{3})(\D|\Z)/B= $2 > 0
ABresult
0X0
100
111
61
62 24 $matches[0] = $2;
63
64 # Try to find month and day.
65 24 ▶ if ($date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])\D+(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/) {
Branch: 13 branches
BranchTrueFalseTotal
if ($date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])\D+(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/) { } 20 4 24
elsif (index($date, 'Jan') != -1) { } 0 4 4
elsif (index($date, 'Feb') != -1) { } 0 4 4
elsif (index($date, 'Mar') != -1) { } 0 4 4
elsif (index($date, 'Apr') != -1) { } 0 4 4
elsif (index($date, 'May') != -1) { } 0 4 4
elsif (index($date, 'Jun') != -1) { } 1 3 4
elsif (index($date, 'Jul') != -1) { } 0 3 3
elsif (index($date, 'Aug') != -1) { } 0 3 3
elsif (index($date, 'Sep') != -1) { } 0 3 3
elsif (index($date, 'Oct') != -1) { } 0 3 3
elsif (index($date, 'Nov') != -1) { } 0 3 3
elsif (index($date, 'Dec') != -1) { } 0 3 3
66 20 ▶ if (($2 < 13 && $3 > 12) || ($2 == $3 && $2 < 13)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($2 < 13 and $3 > 12 or $2 == $3 and $2 < 13) { } 16 4 20
elsif ($3 < 13 and $2 > 12) { } 2 2 4
Condition66%6/9
$2 < 13 and $3 > 12 or $2 == $3 and $2 < 13
l!l&&r!l&&!r
1604
$2 < 13 and $3 > 12
!ll&&!rl&&r
2216
$2 == $3 and $2 < 13
!ll&&!rl&&r
400
MC/DC50%2/4
$2 < 13 and $3 > 12 or $2 == $3 and $2 < 13
$2 < 13 $3 > 12 $2 == $3 $2 < 13
Truth table42%3/7
A and B or C and D
A= $2 < 13B= $3 > 12C= $2 == $3D= $2 < 13
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
67 16 $matches[1] = $2;
68 16 $matches[2] = $3;
69 }
70 ▶ elsif ($3 < 13 && $2 > 12) {
Condition66%2/3
$3 < 13 and $2 > 12
!ll&&!rl&&r
022
MC/DC50%1/2
$3 < 13 and $2 > 12
$3 < 13 $2 > 12
Truth table66%2/3
A and B
A= $3 < 13B= $2 > 12
ABresult
0X0
100
111
71 2 $matches[1] = $3;
72 2 $matches[2] = $2;
73 }
74 }
75 elsif (index($date,'Jan') > -1) {
76 0 $matches[1] = 1;
77 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
78 }
79 elsif (index($date,'Feb') > -1) {
80 0 $matches[1] = 2;
81 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9])(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9])(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9])(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9])(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9])(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9])(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9])(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
82 }
83 elsif (index($date,'Mar') > -1) {
84 0 $matches[1] = 3;
85 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
86 }
87 elsif (index($date,'Apr') > -1) {
88 0 $matches[1] = 4;
89 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
90 }
91 elsif (index($date,'May') > -1) {
92 0 $matches[1] = 5;
93 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
94 }
95 elsif (index($date,'Jun') > -1) {
96 1 $matches[1] = 6;
97 1 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0 1 0 1
Condition33%2/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
001
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
001
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ $2 < 32 $2 > 0
Truth table25%1/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
98 }
99 elsif (index($date,'Jul') > -1) {
100 0 $matches[1] = 7;
101 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
102 }
103 elsif (index($date,'Aug') > -1) {
104 0 $matches[1] = 8;
105 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
106 }
107 elsif (index($date,'Sep') > -1) {
108 0 $matches[1] = 9;
109 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
110 }
111 elsif (index($date,'Oct') > -1) {
112 0 $matches[1] = 10;
113 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
114 }
115 elsif (index($date,'Nov') > -1) {
116 0 $matches[1] = 11;
117 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|30)(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
118 }
119 elsif (index($date,'Dec') > -1) {
120 0 $matches[1] = 12;
121 0 ▶ $matches[2] = $2 if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ && $2 < 32 && $2 > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0 0 0 0
Condition0%0/6
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
!ll&&!rl&&r
000
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32
!ll&&!rl&&r
000
MC/DC0%0/3
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ and $2 < 32 and $2 > 0
$date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/ $2 < 32 $2 > 0
Truth table0%0/4
A and B and C
A= $date =~ /(\A|\D)(0?[1-9]|[1-2][0-9]|3[0-1])(\D|\Z)/B= $2 < 32C= $2 > 0
ABCresult
0XX0
10X0
1100
1111
122 }
123
124 # check month length
125 24 ▶ if (index($matches[1],'?') == -1 && index($matches[2],'?') == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($matches[1], "?") == -1 and index($matches[2], "?") == -1) 19 5 24
Condition66%2/3
index($matches[1], "?") == -1 and index($matches[2], "?") == -1
!ll&&!rl&&r
5019
MC/DC50%1/2
index($matches[1], "?") == -1 and index($matches[2], "?") == -1
index($matches[1], "?") == -1 index($matches[2], "?") == -1
Truth table66%2/3
A and B
A= index($matches[1], "?") == -1B= index($matches[2], "?") == -1
ABresult
0X0
100
111
126 19 ▶ if ($matches[2] == 31 && ($matches[1] == 4 || $matches[1] == 6 || $matches[1] == 9 || $matches[1] == 9 || $matches[1] == 11)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($matches[2] == 31 and $matches[1] == 4 || $matches[1] == 6 || $matches[1] == 9 || $matches[1] == 9 || $matches[1] == 11) { } 4 15 19
elsif ($matches[1] == 2) { } 4 11 15
Condition93%14/15
$matches[2] == 31 and $matches[1] == 4 || $matches[1] == 6 || $matches[1] == 9 || $matches[1] == 9 || $matches[1] == 11
!ll&&!rl&&r
694
$matches[1] == 4 or $matches[1] == 6 or $matches[1] == 9 or $matches[1] == 9 or $matches[1] == 11
l!l&&r!l&&!r
319
$matches[1] == 4 or $matches[1] == 6 or $matches[1] == 9 or $matches[1] == 9
l!l&&r!l&&!r
3010
$matches[1] == 4 or $matches[1] == 6 or $matches[1] == 9
l!l&&r!l&&!r
2110
$matches[1] == 4 or $matches[1] == 6
l!l&&r!l&&!r
1111
MC/DC83%5/6
$matches[2] == 31 and $matches[1] == 4 || $matches[1] == 6 || $matches[1] == 9 || $matches[1] == 9 || $matches[1] == 11
$matches[2] == 31 $matches[1] == 4 $matches[1] == 6 $matches[1] == 9 $matches[1] == 9 $matches[1] == 11
Truth table85%6/7
A and B or C or D or E or F
A= $matches[2] == 31B= $matches[1] == 4C= $matches[1] == 6D= $matches[1] == 9E= $matches[1] == 9F= $matches[1] == 11
ABCDEFresult
0XXXXX0
1000000
11XXXX1
101XXX1
1001XX1
10001X1
1000011
127 4 $matches[1] = '??';
128 4 $matches[2] = '??';
129 }
130 elsif ($matches[1] == 2) {
131 4 ▶ if (($matches[2] == 29 && $matches[0] % 4 == 0 && $matches[0] % 100 > 0) || $matches[2] < 29) {}
Branch: 1 branch
BranchTrueFalseTotal
if ($matches[2] == 29 and $matches[0] % 4 == 0 and $matches[0] % 100 > 0 or $matches[2] < 29) { } 1 3 4
Condition88%8/9
$matches[2] == 29 and $matches[0] % 4 == 0 and $matches[0] % 100 > 0 or $matches[2] < 29
l!l&&r!l&&!r
103
$matches[2] == 29 and $matches[0] % 4 == 0 and $matches[0] % 100 > 0
!ll&&!rl&&r
211
$matches[2] == 29 and $matches[0] % 4 == 0
!ll&&!rl&&r
112
MC/DC75%3/4
$matches[2] == 29 and $matches[0] % 4 == 0 and $matches[0] % 100 > 0 or $matches[2] < 29
$matches[2] == 29 $matches[0] % 4 == 0 $matches[0] % 100 > 0 $matches[2] < 29
Truth table57%4/7
A and B and C or D
A= $matches[2] == 29B= $matches[0] % 4 == 0C= $matches[0] % 100 > 0D= $matches[2] < 29
ABCDresult
111X1
0XX11
10X11
11011
0XX00
10X00
11000
132 else {
133 3 $matches[1] = '??';
134 3 $matches[2] = '??';
135 }
136 }
137 }
138 }
139 }
140 }
141
142 # If incomplete data should be preserved, we must create a DateTime::Incomplete object instead.
143 42 ▶ if ( $self->{ use_incomplete } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'use_incomplete'}) { } 25 17 42
144
145 25 ▶ grep { $_ = undef if index($_,'?') > -1 } @matches;
Branch: 1 branch
BranchTrueFalseTotal
if index($_, "?") != -1 25 50 75
146
147 25 return DateTime::Incomplete->new(
148 year => $matches[0],
149 month => $matches[1],
150 day => $matches[2],
151 formatter => $self,
152 );
153 }
154 # Otherwise the usual DateTime object.
155 else {
156
157 17 ▶ grep { $_ = 1 if index($_,'?') > -1 } @matches;
Branch: 1 branch
BranchTrueFalseTotal
if index($_, "?") != -1 18 33 51
158
159 17 return DateTime->new(
160 year => $matches[0],
161 month => $matches[1],
162 day => $matches[2],
163 formatter => $self,
164 );
165 }
166 }
167  
168  
169 42 ▶sub format_datetime {
Subroutine format_datetime: called CC=4 SCAR=13.9
Pod documented
170 42 my ( $self, $dt ) = @_;
171
172 42 ▶ my $year = (defined $dt->year()) ? $dt->year() : '????';
Branch: 1 branch
BranchTrueFalseTotal
defined $dt->year ? : 40 2 42
173 42 ▶ my $month = (defined $dt->month()) ? $dt->month() : '??';
Branch: 1 branch
BranchTrueFalseTotal
defined $dt->month ? : 30 12 42
174 42 ▶ my $day = (defined $dt->day()) ? $dt->day() : '??';
Branch: 1 branch
BranchTrueFalseTotal
defined $dt->day ? : 31 11 42
175
176 42 return sprintf '%04s.%02s.%02s', $year, $month, $day;
177 }
178  
179 5 1;
180  
181 __END__
↑ Summary