| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::FormFu::Deflator::CompoundDateTime; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
529
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
140
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
11
|
use Moose; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
16
|
|
|
7
|
3
|
|
|
3
|
|
12504
|
use MooseX::Attribute::FormFuChained; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
92
|
|
|
8
|
|
|
|
|
|
|
extends 'HTML::FormFu::Deflator'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
10
|
use HTML::FormFu::Constants qw( $EMPTY_STR ); |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
298
|
|
|
11
|
3
|
|
|
3
|
|
40
|
use DateTime; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
93
|
|
|
12
|
3
|
|
|
3
|
|
10
|
use List::Util 1.33 qw( none ); |
|
|
3
|
|
|
|
|
77
|
|
|
|
3
|
|
|
|
|
170
|
|
|
13
|
3
|
|
|
3
|
|
14
|
use Carp qw( croak ); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
793
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has field_order => ( is => 'rw', traits => ['FormFuChained'] ); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my @known_fields = qw( year month day hour minute second nanosecond time_zone ); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub deflator { |
|
20
|
2
|
|
|
2
|
0
|
3
|
my ( $self, $value ) = @_; |
|
21
|
|
|
|
|
|
|
|
|
22
|
2
|
50
|
33
|
|
|
17
|
return if !defined $value || $value eq $EMPTY_STR; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# do we have a DateTime object? |
|
25
|
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
106
|
eval { $value->$_ for @known_fields }; |
|
|
2
|
|
|
|
|
8
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
2
|
50
|
|
|
|
71
|
return $value if $@; |
|
29
|
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
4
|
my ( $multi, @fields ) = @{ $self->parent->get_fields }; |
|
|
2
|
|
|
|
|
6
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
2
|
100
|
|
|
|
56
|
if ( defined( my $order = $self->field_order ) ) { |
|
33
|
1
|
|
|
|
|
2
|
for my $order (@$order) { |
|
34
|
|
|
|
|
|
|
croak "unknown DateTime field_order name" |
|
35
|
3
|
50
|
|
6
|
|
8
|
if none { $order eq $_ } @known_fields; |
|
|
6
|
|
|
|
|
11
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
6
|
my $field = shift @fields; |
|
38
|
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
6
|
$field->default( $value->$order ); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
else { |
|
43
|
1
|
|
|
|
|
1
|
for my $field (@fields) { |
|
44
|
3
|
|
|
|
|
6
|
my $name = $field->name; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
croak "unknown DateTime field name" |
|
47
|
3
|
50
|
|
6
|
|
8
|
if none { $name eq $_ } @known_fields; |
|
|
6
|
|
|
|
|
12
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
3
|
|
|
|
|
10
|
$field->default( $value->$name ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
8
|
return; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
HTML::FormFu::Deflator::CompoundDateTime - CompoundDateTime deflator |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 VERSION |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
version 2.05 |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
--- |
|
73
|
|
|
|
|
|
|
element: |
|
74
|
|
|
|
|
|
|
- type: Multi |
|
75
|
|
|
|
|
|
|
name: date |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
elements: |
|
78
|
|
|
|
|
|
|
- name: day |
|
79
|
|
|
|
|
|
|
- name: month |
|
80
|
|
|
|
|
|
|
- name: year |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
deflator: |
|
83
|
|
|
|
|
|
|
- type: CompoundDateTime |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# set the default |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$form->get_field('date')->default( $datetime ); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
For use with a L<HTML::FormFu::Element::Multi> group of fields. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Sets the default values of several fields from a single L<DateTime> value. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
By default, expects the field names to be any of the following: |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=over |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item year |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item month |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item day |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item hour |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item minute |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item second |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item nanosecond |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item time_zone |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=back |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 METHODS |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 field_order |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Arguments: \@order |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
If your field names don't follow the convention listed above, you must |
|
124
|
|
|
|
|
|
|
provide an arrayref containing the above names, in the order they correspond |
|
125
|
|
|
|
|
|
|
with your own fields. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
--- |
|
128
|
|
|
|
|
|
|
element: |
|
129
|
|
|
|
|
|
|
- type: Multi |
|
130
|
|
|
|
|
|
|
name: date |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
elements: |
|
133
|
|
|
|
|
|
|
- name: m |
|
134
|
|
|
|
|
|
|
- name: d |
|
135
|
|
|
|
|
|
|
- name: y |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
deflator: |
|
138
|
|
|
|
|
|
|
- type: CompoundDateTime |
|
139
|
|
|
|
|
|
|
field_order: |
|
140
|
|
|
|
|
|
|
- month |
|
141
|
|
|
|
|
|
|
- day |
|
142
|
|
|
|
|
|
|
- year |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Carl Franks |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 LICENSE |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
|
151
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |