line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Checker::Date; |
2
|
|
|
|
|
|
|
# Copyright (c) 2014-2016 Sullivan Beck. All rights reserved. |
3
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it |
4
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
############################################################################### |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require 5.008; |
9
|
3
|
|
|
3
|
|
19
|
use warnings 'all'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
192
|
|
10
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
101
|
|
11
|
3
|
|
|
3
|
|
925
|
use Date::Manip; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our($VERSION); |
14
|
|
|
|
|
|
|
$VERSION='1.07'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
############################################################################### |
17
|
|
|
|
|
|
|
############################################################################### |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub check { |
20
|
|
|
|
|
|
|
my($obj,$element,$desc,$check_opts) = @_; |
21
|
|
|
|
|
|
|
my $err = []; |
22
|
|
|
|
|
|
|
my $warn = []; |
23
|
|
|
|
|
|
|
my $info = []; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# Must be a valid date. |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
# Must be any of the forms supported by Date::Manip. |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $date = ParseDate($element); |
32
|
|
|
|
|
|
|
my $valid = ($date ? 1 : 0); |
33
|
|
|
|
|
|
|
$obj->check_value($check_opts,undef,$element,$valid, |
34
|
|
|
|
|
|
|
"Not a valid date",undef, |
35
|
|
|
|
|
|
|
$err,$warn,$info); |
36
|
|
|
|
|
|
|
return ($element,$err,$warn,$info); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
# Local Variables: |
41
|
|
|
|
|
|
|
# mode: cperl |
42
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
43
|
|
|
|
|
|
|
# cperl-indent-level: 3 |
44
|
|
|
|
|
|
|
# cperl-continued-statement-offset: 2 |
45
|
|
|
|
|
|
|
# cperl-continued-brace-offset: 0 |
46
|
|
|
|
|
|
|
# cperl-brace-offset: 0 |
47
|
|
|
|
|
|
|
# cperl-brace-imaginary-offset: 0 |
48
|
|
|
|
|
|
|
# cperl-label-offset: 0 |
49
|
|
|
|
|
|
|
# End: |