line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Panda::Time; |
2
|
18
|
|
|
18
|
|
601226
|
use parent 'Panda::Export'; |
|
18
|
|
|
|
|
4715
|
|
|
18
|
|
|
|
|
94
|
|
3
|
18
|
|
|
18
|
|
129045
|
use 5.012; |
|
18
|
|
|
|
|
65
|
|
4
|
18
|
|
|
18
|
|
16843
|
use Panda::Lib; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Panda::Install::Payload; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '3.1.2'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Panda::XSLoader; |
10
|
|
|
|
|
|
|
Panda::XSLoader::bootstrap('Panda::Time', $VERSION); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__init__(); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub __init__ { |
15
|
|
|
|
|
|
|
use_embed_zones() unless tzsysdir(); # use embed zones by default where system zones are unavailable |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub use_system_zones { |
19
|
|
|
|
|
|
|
if (tzsysdir()) { |
20
|
|
|
|
|
|
|
tzdir(undef); |
21
|
|
|
|
|
|
|
} else { |
22
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
my $dir = Panda::Install::Payload::payload_dir('Panda::Time'); |
28
|
|
|
|
|
|
|
return tzdir("$dir/zoneinfo"); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub available_zones { |
32
|
|
|
|
|
|
|
my $zones_dir = tzdir() or return; |
33
|
|
|
|
|
|
|
return _scan_zones($zones_dir, ''); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _scan_zones { |
37
|
|
|
|
|
|
|
my ($root, $subdir) = @_; |
38
|
|
|
|
|
|
|
my $dir = $subdir ? "$root/$subdir" : $root; |
39
|
|
|
|
|
|
|
my @list; |
40
|
|
|
|
|
|
|
opendir my $dh, $dir or die "Panda::Time[available_zones]: cannot open $dir: $!"; |
41
|
|
|
|
|
|
|
while (my $entry = readdir $dh) { |
42
|
|
|
|
|
|
|
my $first = substr($entry, 0, 1); |
43
|
|
|
|
|
|
|
next if $first eq '.' or $first eq '_'; |
44
|
|
|
|
|
|
|
my $path = "$dir/$entry"; |
45
|
|
|
|
|
|
|
if (-d $path) { |
46
|
|
|
|
|
|
|
push @list, _scan_zones($root, $subdir ? "$subdir/$entry" : $entry); |
47
|
|
|
|
|
|
|
} elsif (-f $path) { |
48
|
|
|
|
|
|
|
open my $fh, '<', $path or die "Panda::Time[available_zones]: cannot open $path: $!"; |
49
|
|
|
|
|
|
|
my $content = readline $fh; |
50
|
|
|
|
|
|
|
next unless $content =~ /^TZif/; |
51
|
|
|
|
|
|
|
next if $entry =~ /(posixrules|Factory)/; |
52
|
|
|
|
|
|
|
push @list, $subdir ? "$subdir/$entry" : $entry; |
53
|
|
|
|
|
|
|
close $fh; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
closedir $dh; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return @list; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |