File Coverage

blib/lib/DTL/Fast/Filter/Time.pm
Criterion Covered Total %
statement 26 27 96.3
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 34 38 89.4


line stmt bran cond sub pod time code
1             package DTL::Fast::Filter::Time;
2 2     2   755 use strict;
  2         4  
  2         45  
3 2     2   8 use utf8;
  2         3  
  2         11  
4 2     2   39 use warnings FATAL => 'all';
  2         4  
  2         56  
5 2     2   8 use parent 'DTL::Fast::Filter';
  2         3  
  2         12  
6              
7             $DTL::Fast::FILTER_HANDLERS{time} = __PACKAGE__;
8              
9 2     2   111 use DTL::Fast::Utils;
  2         5  
  2         281  
10              
11             #@Override
12             #@todo make pre-defined formats from Django
13             sub parse_parameters
14             {
15 2     2 0 4 my $self = shift;
16 0         0 push @{$self->{parameter}}, DTL::Fast::Variable->new('"TIME_FORMAT"')
17 2 50       3 if (not scalar @{$self->{parameter}});
  2         5  
18 2         5 $self->{format} = $self->{parameter}->[0];
19 2         6 return $self;
20             }
21              
22             #@Override
23             sub filter
24             {
25 2     2 0 3 my $self = shift; # self
26 2         4 shift; # filter_manager
27 2         4 my $value = shift;
28 2         2 my $context = shift;
29              
30 2         12 my $format = $self->{format}->render($context);
31              
32 2         7 return DTL::Fast::Utils::time2str($format, $value);
33             }
34              
35             1;