line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Lite::Constraint::Date; |
2
|
1
|
|
|
1
|
|
573
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
4
|
use FormValidator::Lite::Constraint; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
rule 'DATE' => sub { |
7
|
|
|
|
|
|
|
if (ref $_) { |
8
|
|
|
|
|
|
|
# query: y=2009&m=09&d=02 |
9
|
|
|
|
|
|
|
# rule: {date => [qw/y m d/]} => ['DATE'] |
10
|
|
|
|
|
|
|
return 0 unless scalar(@{$_}) == 3; |
11
|
|
|
|
|
|
|
_v(@{$_}); |
12
|
|
|
|
|
|
|
} else { |
13
|
|
|
|
|
|
|
# query: date=2009-09-02 |
14
|
|
|
|
|
|
|
# rule: date => ['DATE'] |
15
|
|
|
|
|
|
|
_v(split /-/, $_); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _v { |
20
|
4
|
|
|
4
|
|
7
|
my ($y, $m, $d) = @_; |
21
|
|
|
|
|
|
|
|
22
|
4
|
50
|
66
|
|
|
16
|
return 0 if ( !$y or !$m or !$d ); |
|
|
|
33
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
3
|
50
|
33
|
|
|
20
|
if ($d > 31 or $d < 1 or $m > 12 or $m < 1 or $y == 0) { |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
3
|
0
|
0
|
|
|
6
|
if ($d > 30 and ($m == 4 or $m == 6 or $m == 9 or $m == 11)) { |
|
|
|
33
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
return 0; |
29
|
|
|
|
|
|
|
} |
30
|
3
|
100
|
66
|
|
|
7
|
if ($d > 29 and $m == 2) { |
31
|
1
|
|
|
|
|
4
|
return 0; |
32
|
|
|
|
|
|
|
} |
33
|
2
|
50
|
33
|
|
|
11
|
if ($m == 2 and $d > 28 and !($y % 4 == 0 and ($y % 100 != 0 or $y % 400 == 0))){ |
|
|
|
0
|
|
|
|
|
|
|
|
33
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
return 0; |
35
|
|
|
|
|
|
|
} |
36
|
2
|
|
|
|
|
5
|
return 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |