File Coverage

blib/lib/WWW/Shopify/Liquid/Filter/Date.pm
Criterion Covered Total %
statement 16 16 100.0
branch 4 6 66.6
condition 2 6 33.3
subroutine 6 6 100.0
pod 0 3 0.0
total 28 37 75.6


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2 37     37   14757 use strict;
  37         108  
  37         1126  
3 37     37   247 use warnings;
  37         95  
  37         1450  
4              
5 37     37   232 package WWW::Shopify::Liquid::Filter::Date; use base 'WWW::Shopify::Liquid::Filter';
  37         97  
  37         8017  
6 12     12 0 117 sub min_arguments { return 1; }
7 24     24 0 123 sub max_arguments { return 1; }
8             sub operate {
9 8     8 0 39 my ($self, $hash, $operand, @arguments) = @_;
10 8 100       51 return '' unless $operand;
11 7 50 33     81 $operand = DateTime->now if !ref($operand) && $operand eq "now";
12 7 50 33     23 return DateTime->from_epoch( epoch => $operand )->strftime(@arguments) if $operand && !ref($operand);
13 7         90 return $operand->strftime(@arguments);
14             }
15              
16             1;