line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Datum; |
2
|
|
|
|
|
|
|
$VERSION = 0.02; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
80925
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
5
|
use base 'Template::Plugin'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
701
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
3
|
|
|
3
|
1
|
4619
|
my ($self, $context) = @_; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
|
|
13
|
$context->define_filter('datum', \&datum, ''); |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
|
|
52
|
return $self; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub datum { |
16
|
5
|
|
100
|
5
|
0
|
3496
|
my $text = shift || ''; |
17
|
|
|
|
|
|
|
|
18
|
5
|
|
|
|
|
8
|
my @date = (); |
19
|
5
|
|
|
|
|
7
|
my @time = (); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# 8 digits? |
22
|
5
|
100
|
|
|
|
23
|
if ($text =~ /^(\d{4})(\d{2})(\d{2})$/) { |
|
|
100
|
|
|
|
|
|
23
|
1
|
|
|
|
|
4
|
@date = ($1, $2, $3); |
24
|
|
|
|
|
|
|
} elsif ($text =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/) { |
25
|
1
|
|
|
|
|
6
|
@date = ($1, $2, $3); |
26
|
1
|
|
|
|
|
5
|
@time = ($4, $5, $6); |
27
|
|
|
|
|
|
|
} else { |
28
|
|
|
|
|
|
|
# split on '-', '.' or '/' |
29
|
3
|
|
|
|
|
15
|
@date = split(/[-\/.]/, $text); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# wrong? |
33
|
5
|
100
|
|
|
|
19
|
return '' unless (scalar @date == 3); |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
9
|
my $output = join('.', reverse @date); |
36
|
|
|
|
|
|
|
|
37
|
3
|
100
|
|
|
|
8
|
if (scalar @time == 3) { |
38
|
1
|
|
|
|
|
3
|
$output .= ' '.join(':', @time); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
11
|
return $output; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |