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