line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
21
|
|
|
21
|
|
10171
|
use strict; |
|
21
|
|
|
|
|
44
|
|
|
21
|
|
|
|
|
730
|
|
3
|
21
|
|
|
21
|
|
97
|
use warnings; |
|
21
|
|
|
|
|
33
|
|
|
21
|
|
|
|
|
699
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package WWW::Shopify::Liquid::Filter::DateMath; |
6
|
21
|
|
|
21
|
|
95
|
use base 'WWW::Shopify::Liquid::Filter'; |
|
21
|
|
|
|
|
31
|
|
|
21
|
|
|
|
|
4764
|
|
7
|
|
|
|
|
|
|
# +-, #, |
8
|
1
|
|
|
1
|
0
|
24
|
sub min_arguments { return 2; } |
9
|
0
|
|
|
0
|
0
|
|
sub max_arguments { return 2; } |
10
|
|
|
|
|
|
|
sub operate { |
11
|
0
|
|
|
0
|
0
|
|
my ($self, $hash, $operand, @arguments) = @_; |
12
|
0
|
|
|
|
|
|
my ($number, $unit) = @arguments; |
13
|
0
|
|
|
|
|
|
$unit = lc($unit); |
14
|
0
|
0
|
0
|
|
|
|
return undef unless ref($operand) && ref($operand) eq "DateTime"; |
15
|
0
|
0
|
|
|
|
|
return $operand unless $unit =~ m/^(days|months|years|weeks|seconds|minutes|hours)$/; |
16
|
0
|
|
|
|
|
|
return $operand->clone->add( |
17
|
|
|
|
|
|
|
$unit => $number |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |