line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Salvation::TC::Type::Time; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
16
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
116
|
|
4
|
4
|
|
|
4
|
|
14
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
89
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
14
|
use base 'Salvation::TC::Type'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
919
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $re = qr/^(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub Check { |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
1
|
|
my ( $class, $time ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
eval { |
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
0
|
|
|
|
die 'Wrong time format.' if ( ! defined( $time ) || $time !~ $re ); |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my ( $hours, $minutes, $seconds ) = ( $1, $2, $3 ); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
0
|
|
|
|
$seconds ||= '00'; |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
0
|
|
|
|
die "Hours must be bettween 0 and 23. Current value is $hours." unless int( $hours ) >= 0 && int( $hours ) <= 23; |
23
|
0
|
0
|
0
|
|
|
|
die "Minutes must be bettween 0 and 23. Current value is $minutes." unless int( $minutes ) >= 0 && int( $minutes ) <= 59; |
24
|
0
|
0
|
0
|
|
|
|
die "Seconds must be bettween 0 and 23. Current value is $seconds." unless int( $seconds ) >= 0 && int( $seconds ) <= 59; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
if( $@ ) { |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
Salvation::TC::Exception::WrongType -> throw( type => 'Time', value => $time ); |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
__END__ |