line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Processor::Field::DateTimeDMYHM2; |
2
|
|
|
|
|
|
|
$Form::Processor::Field::DateTimeDMYHM2::VERSION = '1.162360'; |
3
|
1
|
|
|
1
|
|
560
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
3
|
use base 'Form::Processor::Field'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
398
|
|
6
|
1
|
|
|
1
|
|
485
|
use Form::Processor; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
24
|
use DateTime; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# This implements a field made up of sub fields. |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
1
|
0
|
sub init_widget {'Compound'} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# This is to keep from reporting missing field |
16
|
|
|
|
|
|
|
# for required fields. Any missing data errors will propogate up. |
17
|
0
|
|
|
0
|
1
|
0
|
sub any_input {1} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Create a sub-form that contains the fields that make up this compound field. |
21
|
|
|
|
|
|
|
sub init { |
22
|
1
|
|
|
1
|
1
|
569
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
6
|
$self->SUPER::init( @_ ); |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
2
|
my $name = $self->name; |
27
|
|
|
|
|
|
|
|
28
|
1
|
50
|
|
|
|
6
|
my $required = $self->required ? 'required' : 'optional'; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
9
|
$self->sub_form( |
31
|
|
|
|
|
|
|
Form::Processor->new( |
32
|
|
|
|
|
|
|
parent_field => $self, # send all errors to parent field. |
33
|
|
|
|
|
|
|
profile => { |
34
|
|
|
|
|
|
|
optional => { |
35
|
|
|
|
|
|
|
day => 'MonthDay', |
36
|
|
|
|
|
|
|
month => 'MonthName', |
37
|
|
|
|
|
|
|
year => 'Year', |
38
|
|
|
|
|
|
|
hour => 'Hour', |
39
|
|
|
|
|
|
|
minute => 'Minute', |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
) |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
2
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub validate { |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
return unless $self->SUPER::validate; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $form = $self->sub_form; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# First validate the sub fields, passing in the original parameters |
58
|
0
|
0
|
|
|
|
|
return unless $form->validate( scalar $self->form->params ); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# This probably should be done in input_to_value() |
62
|
0
|
|
|
|
|
|
my %date = map { $_ => $form->field( $_ )->value } qw/ day month year hour minute /; |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $dt; |
65
|
0
|
|
|
|
|
|
eval { $dt = DateTime->new( %date, time_zone => 'floating' ) }; |
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if ( $@ ) { |
68
|
0
|
|
|
|
|
|
my $error = $@; |
69
|
0
|
|
|
|
|
|
$error =~ s! at /.+$!!; # ! vim |
70
|
0
|
|
|
|
|
|
$self->add_error( "Invalid date [_1]", "$error" ); |
71
|
0
|
|
|
|
|
|
return; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$self->temp( $dt ); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return 1; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub input_to_value { |
80
|
0
|
|
|
0
|
1
|
|
my $field = shift; |
81
|
0
|
|
|
|
|
|
$field->value( $field->temp ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub format_value { |
85
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my $name = $self->name; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my %hash; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
0
|
|
|
|
my $dt = $self->value || return (); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
for my $sub ( qw/ month day year hour minute / ) { |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$hash{ $name . '.' . $sub } = $dt->$sub; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return %hash; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# ABSTRACT: DEPRECATED example of a sub-form |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |