line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Time::Consts; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = 0.03; |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
123243
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
176
|
|
6
|
4
|
|
|
4
|
|
23
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1576
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %ok = map { $_ => 1 } qw/ |
9
|
|
|
|
|
|
|
MSEC |
10
|
|
|
|
|
|
|
SEC |
11
|
|
|
|
|
|
|
MIN |
12
|
|
|
|
|
|
|
HOUR |
13
|
|
|
|
|
|
|
DAY |
14
|
|
|
|
|
|
|
WEEK |
15
|
|
|
|
|
|
|
/; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my %secs = ( |
18
|
|
|
|
|
|
|
MSEC => 1, |
19
|
|
|
|
|
|
|
SEC => 1000 * 1, |
20
|
|
|
|
|
|
|
MIN => 1000 * 60, |
21
|
|
|
|
|
|
|
HOUR => 1000 * 60 * 60, |
22
|
|
|
|
|
|
|
DAY => 1000 * 60 * 60 * 24, |
23
|
|
|
|
|
|
|
WEEK => 1000 * 60 * 60 * 24 * 7, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub import { |
27
|
13
|
|
|
13
|
|
14203
|
shift; |
28
|
|
|
|
|
|
|
|
29
|
13
|
100
|
|
|
|
84
|
return unless @_; |
30
|
|
|
|
|
|
|
|
31
|
9
|
|
|
|
|
26
|
my @args = @_; |
32
|
|
|
|
|
|
|
|
33
|
9
|
100
|
100
|
|
|
109
|
if (my (@bad) = grep !$ok{+uc} && $_ ne ':ALL' => @args) { |
34
|
1
|
|
|
|
|
210
|
croak('Bad argument(s): ' . join ', ' => @bad); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
8
|
|
|
|
|
35
|
my @unit = grep $_ eq lc, @args; |
38
|
8
|
100
|
|
|
|
144
|
croak("Too many units: @unit") if @unit > 1; |
39
|
7
|
|
|
|
|
17
|
push @unit => 'sec'; |
40
|
7
|
|
|
|
|
15
|
my $unit = $secs{uc $unit[0]}; |
41
|
|
|
|
|
|
|
|
42
|
7
|
|
|
|
|
11
|
my @consts = keys %{{ |
|
32
|
|
|
|
|
104
|
|
43
|
22
|
100
|
|
|
|
74
|
map { $_ => 1 } |
44
|
25
|
|
|
|
|
52
|
map { $_ eq ':ALL' ? keys %ok : $_ } |
45
|
7
|
|
|
|
|
15
|
grep { $_ eq uc } |
46
|
|
|
|
|
|
|
@args |
47
|
|
|
|
|
|
|
}}; |
48
|
|
|
|
|
|
|
|
49
|
7
|
|
|
|
|
43
|
my $pkg = caller; |
50
|
|
|
|
|
|
|
|
51
|
7
|
|
|
|
|
16
|
for (@consts) { |
52
|
32
|
|
|
|
|
60
|
my $t = $secs{$_} / $unit; |
53
|
|
|
|
|
|
|
|
54
|
4
|
|
|
4
|
|
32
|
no strict 'refs'; |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
596
|
|
55
|
32
|
|
|
0
|
|
188
|
*{"$pkg\::$_"} = sub () { $t }; |
|
32
|
|
|
|
|
3617
|
|
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__PACKAGE__; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |