| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dancer::Plugin::Formatter; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our @ISA = qw(); |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
46608
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
90
|
|
|
7
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
64
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
1871
|
use Dancer ':syntax'; |
|
|
3
|
|
|
|
|
546637
|
|
|
|
3
|
|
|
|
|
17
|
|
|
10
|
3
|
|
|
3
|
|
2438
|
use Dancer::Plugin; |
|
|
3
|
|
|
|
|
3485
|
|
|
|
3
|
|
|
|
|
194
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
1195
|
use Date::Parse; |
|
|
3
|
|
|
|
|
11216
|
|
|
|
3
|
|
|
|
|
314
|
|
|
13
|
3
|
|
|
3
|
|
1384
|
use POSIX; |
|
|
3
|
|
|
|
|
14171
|
|
|
|
3
|
|
|
|
|
16
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# see man 3 strftime |
|
16
|
|
|
|
|
|
|
our $default_date_format = '%x'; # The preferred date representation for the current locale without the time. |
|
17
|
|
|
|
|
|
|
our $default_time_format = '%c'; # The preferred date and time representation for the current locale. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
register 'format_date' => sub { |
|
20
|
2
|
|
33
|
2
|
|
15
|
my $format = shift // $default_date_format; |
|
21
|
|
|
|
|
|
|
return sub { |
|
22
|
3
|
|
|
3
|
|
8
|
my $date = shift; |
|
23
|
3
|
100
|
|
|
|
11
|
return undef unless defined $date; |
|
24
|
2
|
100
|
|
|
|
11
|
return '' if $date eq ''; |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
100
|
|
|
28
|
my @parts = map { $_ //= 0 } strptime $date; |
|
|
7
|
|
|
|
|
145
|
|
|
27
|
|
|
|
|
|
|
# undefined parts set to 0 to prevent error |
|
28
|
|
|
|
|
|
|
# Use of uninitialized value in subroutine entry |
|
29
|
1
|
|
|
|
|
63
|
return POSIX::strftime $format, @parts; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
2
|
|
|
|
|
13
|
}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
register 'format_time' => sub { |
|
34
|
0
|
|
0
|
0
|
|
|
my $format = shift // $default_time_format; |
|
35
|
|
|
|
|
|
|
return sub { |
|
36
|
0
|
|
|
0
|
|
|
my $time = shift; |
|
37
|
0
|
0
|
|
|
|
|
return undef unless defined $time; |
|
38
|
0
|
0
|
|
|
|
|
return '' if $time eq ''; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
0
|
|
|
|
my @parts = map { $_ //= 0 } strptime $time; |
|
|
0
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# undefined parts set to 0 to prevent error |
|
42
|
|
|
|
|
|
|
# Use of uninitialized value in subroutine entry |
|
43
|
0
|
|
|
|
|
|
return POSIX::strftime $format, @parts; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
0
|
|
|
|
|
|
}; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
register 'set_default_date_format' => sub { |
|
48
|
0
|
|
|
0
|
|
|
$default_date_format = shift; |
|
49
|
0
|
|
|
|
|
|
return; |
|
50
|
|
|
|
|
|
|
}; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
register 'set_default_time_format' => sub { |
|
53
|
0
|
|
|
0
|
|
|
$default_time_format = shift; |
|
54
|
0
|
|
|
|
|
|
return; |
|
55
|
|
|
|
|
|
|
}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
register 'format' => sub { |
|
59
|
0
|
|
|
0
|
|
|
my $format = shift; |
|
60
|
|
|
|
|
|
|
return sub { |
|
61
|
0
|
|
|
0
|
|
|
return sprintf $format, @_; |
|
62
|
0
|
|
|
|
|
|
}; |
|
63
|
|
|
|
|
|
|
}; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
register_plugin; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |