line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::DateTime::Format; |
2
|
|
|
|
|
|
|
$Template::Plugin::DateTime::Format::VERSION = '0.03'; |
3
|
|
|
|
|
|
|
# ABSTRACT: format DateTime objects from inside TT with DateTime::Format-style formatters |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
63962
|
use 5.006; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
6
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
57
|
|
7
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
51
|
|
8
|
2
|
|
|
2
|
|
763
|
use DateTime; |
|
2
|
|
|
|
|
133747
|
|
|
2
|
|
|
|
|
64
|
|
9
|
2
|
|
|
2
|
|
16
|
use Class::Load; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
100
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
9
|
use base 'Template::Plugin'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1469
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
3
|
|
|
3
|
1
|
7491
|
my ($class, $context, $formatter_class, $new_args, $format_args) = @_; |
15
|
3
|
|
100
|
|
|
21
|
Class::Load::load_class($formatter_class || die 'need class name'); |
16
|
|
|
|
|
|
|
|
17
|
1
|
50
|
|
|
|
80
|
my @new_args = ref $new_args eq 'ARRAY' ? @$new_args : $new_args; |
18
|
2
|
|
|
2
|
|
5704
|
{ no warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
217
|
|
|
1
|
|
|
|
|
2
|
|
19
|
1
|
50
|
|
|
|
4
|
$format_args = [ $format_args ] unless ref $format_args eq 'ARRAY'; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
bless { |
23
|
1
|
|
|
|
|
5
|
_CONTEXT => $context, |
24
|
|
|
|
|
|
|
formatter => $formatter_class->new(@new_args), |
25
|
|
|
|
|
|
|
format_args => $format_args, |
26
|
|
|
|
|
|
|
}, $class; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub format { |
30
|
1
|
|
|
1
|
1
|
33
|
my ($self, $date) = @_; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
6
|
my $fmt = $self->{formatter}; |
33
|
1
|
|
|
|
|
2
|
my @args = $self->{format_args}; |
34
|
1
|
|
|
|
|
3
|
return $fmt->format_datetime($date, @args); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |