line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## no critic: Modules::ProhibitAutomaticExportation |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Date::strftimeq; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $DATE = '2020-02-01'; # DATE |
6
|
|
|
|
|
|
|
our $DIST = 'Date-strftimeq'; # DIST |
7
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
53806
|
use 5.010001; |
|
1
|
|
|
|
|
11
|
|
10
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
11
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
368
|
use POSIX (); |
|
1
|
|
|
|
|
5183
|
|
|
1
|
|
|
|
|
24
|
|
14
|
1
|
|
|
1
|
|
5
|
use Scalar::Util 'blessed'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
5
|
use Exporter 'import'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
159
|
|
17
|
|
|
|
|
|
|
our @EXPORT = qw(strftimeq); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $regex = qr{ |
20
|
|
|
|
|
|
|
(?(DEFINE) |
21
|
|
|
|
|
|
|
(? ( [^()]+ | \((?&def_code)\) )*) |
22
|
|
|
|
|
|
|
) |
23
|
|
|
|
|
|
|
(? |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
(? |
26
|
|
|
|
|
|
|
% |
27
|
|
|
|
|
|
|
(? [_0^#-]+)? |
28
|
|
|
|
|
|
|
(? [0-9]+)? |
29
|
|
|
|
|
|
|
(?[EO])? |
30
|
|
|
|
|
|
|
(? [%aAbBcCdDeEFgGhHIjklmMnOpPrRsStTuUVwWxXyYZz+]) |
31
|
|
|
|
|
|
|
)| |
32
|
|
|
|
|
|
|
(? |
33
|
|
|
|
|
|
|
%\( |
34
|
|
|
|
|
|
|
(? (?&def_code)) |
35
|
|
|
|
|
|
|
\)q) |
36
|
|
|
|
|
|
|
) |
37
|
|
|
|
|
|
|
}x; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# faster version, without using named capture |
40
|
|
|
|
|
|
|
if (0) { |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub strftimeq { |
44
|
5
|
|
|
5
|
1
|
2082
|
my ($format, @time) = @_; |
45
|
|
|
|
|
|
|
|
46
|
5
|
|
|
|
|
14
|
my ($caller_pkg) = caller(); |
47
|
5
|
|
|
|
|
8
|
my %compiled_code; |
48
|
|
|
|
|
|
|
|
49
|
5
|
|
|
|
|
36
|
$format =~ s{$regex}{ |
50
|
|
|
|
|
|
|
# for faster acccess |
51
|
1
|
|
|
1
|
|
365
|
my %m = %+; |
|
1
|
|
|
|
|
259
|
|
|
1
|
|
|
|
|
145
|
|
|
16
|
|
|
|
|
142
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#use DD; dd \%m; # DEBUG |
54
|
|
|
|
|
|
|
|
55
|
16
|
100
|
|
|
|
43
|
if (exists $m{code}) { |
56
|
3
|
50
|
|
|
|
16
|
unless (defined $compiled_code{$m{code}}) { |
57
|
|
|
|
|
|
|
#say "D: compiling $m{code}"; # DEBUG |
58
|
1
|
|
|
1
|
|
6
|
$compiled_code{$m{code}} = eval "package $caller_pkg; no strict; no warnings; sub { $m{code} }"; |
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
22
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
56
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
59
|
|
|
3
|
|
|
|
|
157
|
|
59
|
3
|
50
|
|
|
|
9
|
die "Can't compile code in $m{all}: $@" if $@; |
60
|
|
|
|
|
|
|
} |
61
|
3
|
|
|
|
|
61
|
my $code_res = $compiled_code{$m{code}}->(@time); |
62
|
3
|
|
50
|
|
|
112
|
$code_res //= ""; |
63
|
3
|
|
|
|
|
5
|
$code_res =~ s/%/%%/g; |
64
|
3
|
|
|
|
|
11
|
$code_res; |
65
|
|
|
|
|
|
|
} else { |
66
|
13
|
|
|
|
|
90
|
$m{all}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
}xego; |
69
|
|
|
|
|
|
|
|
70
|
5
|
|
|
|
|
182
|
POSIX::strftime($format, @time); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
# ABSTRACT: POSIX::strftime() with support for embedded perl code in %(...)q |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |