File Coverage

blib/lib/Apache/Voodoo/Validate/datetime.pm
Criterion Covered Total %
statement 31 32 96.8
branch 5 6 83.3
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 43 47 91.4


line stmt bran cond sub pod time code
1             package Apache::Voodoo::Validate::datetime;
2              
3 2     2   1471 use strict;
  2         4  
  2         107  
4 2     2   12 use warnings;
  2         38  
  2         79  
5              
6 2     2   12 use base("Apache::Voodoo::Validate::Plugin");
  2         3  
  2         1846  
7              
8 2     2   1570 use Apache::Voodoo::Validate::date;
  2         8  
  2         68  
9 2     2   1571 use Apache::Voodoo::Validate::time;
  2         5  
  2         525  
10              
11             sub config {
12 1     1 0 2 my ($self,$c) = @_;
13              
14 1         3 my @e;
15 1         3 push(@e,Apache::Voodoo::Validate::date::config($self,@_));
16 1         5 push(@e,Apache::Voodoo::Validate::time::config($self,@_));
17 1         59 return @e;
18             }
19              
20             sub valid {
21 2     2 0 5 my ($self,$v) = @_;
22              
23 2         8 my ($d,$t) = split(/ /,$v);
24              
25 2         13 my ($vd,$ed) = Apache::Voodoo::Validate::date::valid($self,$d);
26 2         12 my ($vt,$et) = Apache::Voodoo::Validate::time::valid($self,$t);
27              
28 2         4 my @e;
29 2 50       5 if ($ed) {
30 0         0 push(@e,$ed);
31             }
32              
33 2 100       6 if ($et) {
34 1         3 push(@e,$et);
35             }
36              
37 2 100       6 if (scalar @e) {
38 1         11 return undef,@e;
39             }
40             else {
41 1         6 return "$vd $vt";
42             }
43             }
44              
45             1;
46              
47             ################################################################################
48             # Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org).
49             # All rights reserved.
50             #
51             # You may use and distribute Apache::Voodoo under the terms described in the
52             # LICENSE file include in this package. The summary is it's a legalese version
53             # of the Artistic License :)
54             #
55             ################################################################################