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   1265 use strict; use utf8; use warnings FATAL => 'all';
  2     2   4  
  2     2   49  
  2         11  
  2         4  
  2         9  
  2         50  
  2         4  
  2         70  
3 2     2   10 use parent 'DTL::Fast::Filter';
  2         4  
  2         12  
4              
5             $DTL::Fast::FILTER_HANDLERS{'time'} = __PACKAGE__;
6              
7 2     2   119 use DTL::Fast::Utils;
  2         5  
  2         377  
8              
9             #@Override
10             #@todo make pre-defined formats from Django
11             sub parse_parameters
12             {
13 2     2 0 4 my $self = shift;
14 0         0 push @{$self->{'parameter'}}, DTL::Fast::Variable->new('"TIME_FORMAT"')
15 2 50       2 if not scalar @{$self->{'parameter'}};
  2         6  
16 2         5 $self->{'format'} = $self->{'parameter'}->[0];
17 2         8 return $self;
18             }
19              
20             #@Override
21             sub filter
22             {
23 2     2 0 3 my $self = shift; # self
24 2         2 shift; # filter_manager
25 2         4 my $value = shift;
26 2         3 my $context = shift;
27            
28 2         12 my $format = $self->{'format'}->render($context);
29            
30 2         6 return DTL::Fast::Utils::time2str($format, $value);
31             }
32              
33             1;