File Coverage

blib/lib/Salvation/TC/Type/Date/Reverse.pm
Criterion Covered Total %
statement 12 19 63.1
branch 0 4 0.0
condition 0 3 0.0
subroutine 4 5 80.0
pod 1 1 100.0
total 17 32 53.1


line stmt bran cond sub pod time code
1             package Salvation::TC::Type::Date::Reverse;
2              
3 4     4   1255 use strict;
  4         5  
  4         136  
4 4     4   14 use warnings;
  4         4  
  4         88  
5              
6 4     4   12 use base 'Salvation::TC::Type::Date';
  4         6  
  4         3237  
7              
8 4     4   25 use Salvation::TC::Exception::WrongType ();
  4         4  
  4         460  
9              
10             my $re = qr/^(\d{4})[\.\/\-](\d{1,2})[\.\/\-](\d{1,2})\s*(\d+:\d+(:\d+)*?)?$/;
11              
12             sub Check {
13              
14 0     0 1   my ( $class, $date ) = @_;
15              
16 0           eval {
17              
18 0 0 0       die "Wrong date format. Expected year[.-/]month[./-]day time" if ( ! defined( $date ) || $date !~ $re );
19              
20 0           my ( $year, $month, $day, $time ) = ( $1, $2, $3, $4 );
21              
22 0           $class->SUPER::Check( "$day.$month.$year $time" );
23             };
24              
25 0 0         if( $@ ) {
26              
27 0           Salvation::TC::Exception::WrongType -> throw( type => 'Date::Reverse', value => $date );
28             };
29             }
30              
31             1;
32             __END__