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