File Coverage

blib/lib/Value/Object/W3CDateTime.pm
Criterion Covered Total %
statement 22 22 100.0
branch 10 10 100.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 37 37 100.0


line stmt bran cond sub pod time code
1             package Value::Object::W3CDateTime;
2              
3 3     3   24783 use strict;
  3         6  
  3         68  
4 3     3   15 use warnings;
  3         4  
  3         72  
5              
6 3     3   1126 use Value::Object::ValidationUtils;
  3         7  
  3         86  
7              
8 3     3   636 use parent 'Value::Object';
  3         304  
  3         104  
9              
10             our $VERSION = '0.13';
11              
12             sub _why_invalid
13             {
14 44     44   60 my ( $self, $value ) = @_;
15 44 100       90 return ( ref($self) . ': value is undefined', '', undef ) unless defined $value;
16 43 100       85 return ( ref($self) . ': value is empty', '', undef ) unless length $value;
17 42 100       103 return ( ref($self) . ': value is mssing time separator', '', undef )
18             unless $value =~ tr/T//;
19 37         94 my ($date, $time) = split /T/, $value;
20 37         121 my ($why, $long, $data) = Value::Object::ValidationUtils::why_invalid_iso_8601_date( $date );
21 37 100       125 return ( ref($self) . ": $why", $long, $data ) if defined $why;
22              
23 21         52 ($why, $long, $data) = Value::Object::ValidationUtils::why_invalid_iso_8601_time( $time );
24 21 100       110 return ( ref($self) . ": $why", $long, $data ) if defined $why;
25 2         6 return;
26             }
27              
28             1;
29             __END__