line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Untaint::datetime; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7246
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
5
|
use base 'CGI::Untaint::printable'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
752
|
|
5
|
1
|
|
|
1
|
|
2007
|
use Time::Piece; |
|
1
|
|
|
|
|
13743
|
|
|
1
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
91
|
use vars qw/$VERSION/; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
186
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.06'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub is_valid { |
11
|
5
|
|
|
5
|
1
|
5094
|
my $self=shift; |
12
|
5
|
|
|
|
|
9
|
my $date; |
13
|
5
|
|
|
|
|
20
|
my $val=$self->value; |
14
|
5
|
100
|
|
|
|
47
|
$val.=":00" if length($val) ==16; |
15
|
5
|
50
|
|
|
|
19
|
substr($val,10,1,"T") if length($val) ==19; |
16
|
5
|
50
|
|
|
|
11
|
eval { |
17
|
5
|
0
|
|
|
|
25
|
$date=Time::Piece->strptime($val,"%FT%H:%M:%S") |
18
|
|
|
|
|
|
|
or return; |
19
|
|
|
|
|
|
|
} or return; |
20
|
0
|
|
|
|
|
|
$self->value($date); |
21
|
0
|
|
|
|
|
|
return $date; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
CGI::Untaint::datetime - validate a date |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use CGI::Untaint; |
31
|
|
|
|
|
|
|
my $handler = CGI::Untaint->new($q->Vars); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $date = $handler->extract(-as_datetime => 'timestamp'); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This Input Handler verifies that the input is a valid datetime, as |
38
|
|
|
|
|
|
|
specified by ISO 8601, that is, something resembling YYYY-MM-DDTHH:MM:SS |
39
|
|
|
|
|
|
|
it can even handle YYYY-MM-DD HH::MM::SS or YYYY-MM-D HH::MM |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over 4 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item is_valid |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
The actual validation check. See CGI::Untaint for more information. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=back |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SEE ALSO |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
L. L |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 AUTHOR |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Marcus Ramberg |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 COPYRIGHT |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Copyright (C) 2004 Marcus Ramberg. All rights reserved. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify |
64
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |