line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Panda::Time; |
2
|
18
|
|
|
18
|
|
554911
|
use parent 'Panda::Export'; |
|
18
|
|
|
|
|
4671
|
|
|
18
|
|
|
|
|
98
|
|
3
|
18
|
|
|
18
|
|
111910
|
use 5.012; |
|
18
|
|
|
|
|
64
|
|
4
|
18
|
|
|
18
|
|
106
|
use CPP::panda::lib; |
|
18
|
|
|
|
|
39
|
|
|
18
|
|
|
|
|
428
|
|
5
|
18
|
|
|
18
|
|
88
|
use Panda::Install::Payload; |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
7897
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '3.1.3'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Panda::XSLoader; |
10
|
|
|
|
|
|
|
Panda::XSLoader::bootstrap('Panda::Time', $VERSION); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__init__(); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub __init__ { |
15
|
18
|
50
|
|
18
|
|
244
|
use_embed_zones() unless tzsysdir(); # use embed zones by default where system zones are unavailable |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub use_system_zones { |
19
|
0
|
0
|
|
0
|
0
|
0
|
if (tzsysdir()) { |
20
|
0
|
|
|
|
|
0
|
tzdir(undef); |
21
|
|
|
|
|
|
|
} else { |
22
|
0
|
|
|
|
|
0
|
warn("Panda::Time[use_system_zones]: this OS has no olson timezone files, you cant use system zones"); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub use_embed_zones { |
27
|
17
|
|
|
17
|
0
|
8309
|
my $dir = Panda::Install::Payload::payload_dir('Panda::Time'); |
28
|
17
|
|
|
|
|
1109
|
return tzdir("$dir/zoneinfo"); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub available_zones { |
32
|
3
|
50
|
|
3
|
0
|
91967
|
my $zones_dir = tzdir() or return; |
33
|
3
|
|
|
|
|
19
|
return _scan_zones($zones_dir, ''); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _scan_zones { |
37
|
89
|
|
|
89
|
|
213
|
my ($root, $subdir) = @_; |
38
|
89
|
100
|
|
|
|
206
|
my $dir = $subdir ? "$root/$subdir" : $root; |
39
|
89
|
|
|
|
|
133
|
my @list; |
40
|
89
|
50
|
|
|
|
2085
|
opendir my $dh, $dir or die "Panda::Time[available_zones]: cannot open $dir: $!"; |
41
|
89
|
|
|
|
|
2081
|
while (my $entry = readdir $dh) { |
42
|
2698
|
|
|
|
|
5344
|
my $first = substr($entry, 0, 1); |
43
|
2698
|
100
|
66
|
|
|
10329
|
next if $first eq '.' or $first eq '_'; |
44
|
2520
|
|
|
|
|
4625
|
my $path = "$dir/$entry"; |
45
|
2520
|
100
|
|
|
|
64770
|
if (-d $path) { |
|
|
50
|
|
|
|
|
|
46
|
86
|
100
|
|
|
|
359
|
push @list, _scan_zones($root, $subdir ? "$subdir/$entry" : $entry); |
47
|
|
|
|
|
|
|
} elsif (-f $path) { |
48
|
2434
|
50
|
|
|
|
54298
|
open my $fh, '<', $path or die "Panda::Time[available_zones]: cannot open $path: $!"; |
49
|
2434
|
|
|
|
|
15397
|
my $content = readline $fh; |
50
|
2434
|
100
|
|
|
|
9482
|
next unless $content =~ /^TZif/; |
51
|
2428
|
100
|
|
|
|
6823
|
next if $entry =~ /(posixrules|Factory)/; |
52
|
2422
|
100
|
|
|
|
7414
|
push @list, $subdir ? "$subdir/$entry" : $entry; |
53
|
2422
|
|
|
|
|
17802
|
close $fh; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
89
|
|
|
|
|
553
|
closedir $dh; |
57
|
|
|
|
|
|
|
|
58
|
89
|
|
|
|
|
1567
|
return @list; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |