line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
9
|
|
|
9
|
|
4747
|
use strict; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
604
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTML::FormFu::Deflator::Strftime; |
4
|
|
|
|
|
|
|
$HTML::FormFu::Deflator::Strftime::VERSION = '2.07'; |
5
|
|
|
|
|
|
|
# ABSTRACT: Strftime deflator |
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
56
|
use Moose; |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
75
|
|
8
|
9
|
|
|
9
|
|
64133
|
use MooseX::Attribute::Chained; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
1722
|
|
9
|
|
|
|
|
|
|
extends 'HTML::FormFu::Deflator'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has strftime => ( is => 'rw', traits => ['Chained'] ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub deflator { |
14
|
13
|
|
|
13
|
0
|
51
|
my ( $self, $value ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
13
|
|
|
|
|
33
|
my $return; |
17
|
|
|
|
|
|
|
|
18
|
13
|
|
|
|
|
43
|
eval { |
19
|
13
|
|
|
|
|
91
|
my $locale = $self->locale; |
20
|
|
|
|
|
|
|
|
21
|
13
|
50
|
|
|
|
62
|
$value->set_locale($locale) if defined $locale; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
13
|
|
|
|
|
41
|
eval { $return = $value->strftime( $self->strftime ) }; |
|
13
|
|
|
|
|
458
|
|
25
|
|
|
|
|
|
|
|
26
|
13
|
100
|
|
|
|
1469
|
if ($@) { |
27
|
4
|
|
|
|
|
13
|
$return = $value; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
13
|
|
|
|
|
67
|
return $return; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=encoding UTF-8 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
HTML::FormFu::Deflator::Strftime - Strftime deflator |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 VERSION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
version 2.07 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$form->deflator( Strftime => 'start_time' ) |
54
|
|
|
|
|
|
|
->strftime( '%d/%m/%Y' ); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
--- |
57
|
|
|
|
|
|
|
elements: |
58
|
|
|
|
|
|
|
- type: Text |
59
|
|
|
|
|
|
|
inflators: |
60
|
|
|
|
|
|
|
- type: DateTime |
61
|
|
|
|
|
|
|
parser: |
62
|
|
|
|
|
|
|
strptime: "%Y/%m/%d" |
63
|
|
|
|
|
|
|
deflator: |
64
|
|
|
|
|
|
|
- type: Strftime |
65
|
|
|
|
|
|
|
strftime: "%Y/%m/%d" |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Strftime deflator for L<DateTime> objects. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
When you redisplay a form to the user following an invalid submission, |
72
|
|
|
|
|
|
|
any fields with DateTime inflators will stringify to something like |
73
|
|
|
|
|
|
|
'1970-01-01T00:00:00'. In most cases it makes more sense to use the same |
74
|
|
|
|
|
|
|
format you've asked the user for. This deflator allows you to specify a |
75
|
|
|
|
|
|
|
more suitable and user-friendly format. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This deflator calls L<DateTime>'s C<strftime> method. Possible values for |
78
|
|
|
|
|
|
|
the format string are documented at |
79
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/DateTime/lib/DateTime.pm#strftime_Patterns>. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
If you set the form's locale (see L<HTML::FormFu/locale>) this is set on the DateTime object. Now you can use C<%x> to get the default date or C<%X> for the default time for the object's locale. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Carl Franks, C<cfranks@cpan.org> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 LICENSE |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
90
|
|
|
|
|
|
|
the same terms as Perl itself. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Carl Franks <cpan@fireartist.com> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Carl Franks. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
101
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |