line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Plugin::Formatter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our @ISA = qw(); |
4
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
65006
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
133
|
|
7
|
4
|
|
|
4
|
|
15
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
133
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
2414
|
use Dancer ':syntax'; |
|
4
|
|
|
|
|
797293
|
|
|
4
|
|
|
|
|
20
|
|
10
|
4
|
|
|
4
|
|
3097
|
use Dancer::Plugin; |
|
4
|
|
|
|
|
4718
|
|
|
4
|
|
|
|
|
261
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
1818
|
use Date::Parse; |
|
4
|
|
|
|
|
15791
|
|
|
4
|
|
|
|
|
481
|
|
13
|
4
|
|
|
4
|
|
2048
|
use POSIX; |
|
4
|
|
|
|
|
20028
|
|
|
4
|
|
|
|
|
22
|
|
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
|
3
|
|
33
|
3
|
|
36
|
my $format = shift // $default_date_format; |
21
|
|
|
|
|
|
|
return sub { |
22
|
4
|
|
|
4
|
|
11
|
my $date = shift; |
23
|
4
|
100
|
|
|
|
17
|
return undef unless defined $date; |
24
|
3
|
100
|
|
|
|
19
|
return '' if $date eq ''; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
100
|
|
|
77
|
my @parts = map { $_ //= 0 } strptime $date; |
|
7
|
|
|
|
|
152
|
|
27
|
|
|
|
|
|
|
# undefined parts set to 0 to prevent error |
28
|
|
|
|
|
|
|
# Use of uninitialized value in subroutine entry |
29
|
|
|
|
|
|
|
|
30
|
2
|
100
|
|
|
|
501
|
@parts = localtime $date |
31
|
|
|
|
|
|
|
if $date =~ /^\d+$/; # unixtime - seconds since epoch |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
117
|
return POSIX::strftime $format, @parts; |
34
|
|
|
|
|
|
|
} |
35
|
3
|
|
|
|
|
26
|
}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
register 'format_time' => sub { |
38
|
0
|
|
0
|
0
|
|
|
my $format = shift // $default_time_format; |
39
|
|
|
|
|
|
|
return sub { |
40
|
0
|
|
|
0
|
|
|
my $time = shift; |
41
|
0
|
0
|
|
|
|
|
return undef unless defined $time; |
42
|
0
|
0
|
|
|
|
|
return '' if $time eq ''; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
0
|
|
|
|
my @parts = map { $_ //= 0 } strptime $time; |
|
0
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# undefined parts set to 0 to prevent error |
46
|
|
|
|
|
|
|
# Use of uninitialized value in subroutine entry |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
@parts = localtime $time |
49
|
|
|
|
|
|
|
if $time =~ /^\d+$/; # unixtime - seconds since epoch |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return POSIX::strftime $format, @parts; |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
register 'set_default_date_format' => sub { |
56
|
0
|
|
|
0
|
|
|
$default_date_format = shift; |
57
|
0
|
|
|
|
|
|
return; |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
register 'set_default_time_format' => sub { |
61
|
0
|
|
|
0
|
|
|
$default_time_format = shift; |
62
|
0
|
|
|
|
|
|
return; |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
register 'format' => sub { |
67
|
0
|
|
|
0
|
|
|
my $format = shift; |
68
|
|
|
|
|
|
|
return sub { |
69
|
0
|
|
|
0
|
|
|
return sprintf $format, @_; |
70
|
0
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
register_plugin; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |