line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Panda::Time; |
2
|
18
|
|
|
18
|
|
1268100
|
use parent 'Panda::Export'; |
|
18
|
|
|
|
|
4563
|
|
|
18
|
|
|
|
|
78
|
|
3
|
18
|
|
|
18
|
|
111066
|
use 5.012; |
|
18
|
|
|
|
|
46
|
|
4
|
18
|
|
|
18
|
|
88
|
use CPP::panda::lib; |
|
18
|
|
|
|
|
27
|
|
|
18
|
|
|
|
|
361
|
|
5
|
18
|
|
|
18
|
|
74
|
use Panda::Install::Payload; |
|
18
|
|
|
|
|
26
|
|
|
18
|
|
|
|
|
8086
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '3.1.5'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Panda::XSLoader; |
10
|
|
|
|
|
|
|
Panda::XSLoader::bootstrap('Panda::Time', $VERSION); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__init__(); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub __init__ { |
15
|
18
|
50
|
|
18
|
|
125
|
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
|
6580
|
my $dir = Panda::Install::Payload::payload_dir('Panda::Time'); |
28
|
17
|
|
|
|
|
1739
|
return tzdir("$dir/zoneinfo"); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub available_zones { |
32
|
3
|
50
|
|
3
|
0
|
85888
|
my $zones_dir = tzdir() or return; |
33
|
3
|
|
|
|
|
13
|
return _scan_zones($zones_dir, ''); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _scan_zones { |
37
|
89
|
|
|
89
|
|
182
|
my ($root, $subdir) = @_; |
38
|
89
|
100
|
|
|
|
169
|
my $dir = $subdir ? "$root/$subdir" : $root; |
39
|
89
|
|
|
|
|
91
|
my @list; |
40
|
89
|
50
|
|
|
|
2098
|
opendir my $dh, $dir or die "Panda::Time[available_zones]: cannot open $dir: $!"; |
41
|
89
|
|
|
|
|
2197
|
while (my $entry = readdir $dh) { |
42
|
2700
|
|
|
|
|
5054
|
my $first = substr($entry, 0, 1); |
43
|
2700
|
100
|
66
|
|
|
12274
|
next if $first eq '.' or $first eq '_'; |
44
|
2522
|
|
|
|
|
3924
|
my $path = "$dir/$entry"; |
45
|
2522
|
100
|
|
|
|
70264
|
if (-d $path) { |
|
|
50
|
|
|
|
|
|
46
|
86
|
100
|
|
|
|
347
|
push @list, _scan_zones($root, $subdir ? "$subdir/$entry" : $entry); |
47
|
|
|
|
|
|
|
} elsif (-f $path) { |
48
|
2436
|
50
|
|
|
|
70565
|
open my $fh, '<', $path or die "Panda::Time[available_zones]: cannot open $path: $!"; |
49
|
2436
|
|
|
|
|
22432
|
my $content = readline $fh; |
50
|
2436
|
100
|
|
|
|
9716
|
next unless $content =~ /^TZif/; |
51
|
2428
|
100
|
|
|
|
5955
|
next if $entry =~ /(posixrules|Factory)/; |
52
|
2422
|
100
|
|
|
|
7051
|
push @list, $subdir ? "$subdir/$entry" : $entry; |
53
|
2422
|
|
|
|
|
30912
|
close $fh; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
89
|
|
|
|
|
852
|
closedir $dh; |
57
|
|
|
|
|
|
|
|
58
|
89
|
|
|
|
|
1501
|
return @list; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |