line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTimeX::Lite::TimeZone::Local; |
2
|
|
|
|
|
|
|
|
3
|
56
|
|
|
56
|
|
1878
|
use strict; |
|
56
|
|
|
|
|
126
|
|
|
56
|
|
|
|
|
3152
|
|
4
|
56
|
|
|
56
|
|
327
|
use warnings; |
|
56
|
|
|
|
|
98
|
|
|
56
|
|
|
|
|
3267
|
|
5
|
|
|
|
|
|
|
|
6
|
56
|
|
|
56
|
|
1526
|
use DateTimeX::Lite::TimeZone; |
|
56
|
|
|
|
|
97
|
|
|
56
|
|
|
|
|
1442
|
|
7
|
56
|
|
|
56
|
|
313
|
use File::Spec; |
|
56
|
|
|
|
|
97
|
|
|
56
|
|
|
|
|
104971
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub TimeZone |
11
|
|
|
|
|
|
|
{ |
12
|
539
|
|
|
539
|
1
|
387921
|
my $class = shift; |
13
|
|
|
|
|
|
|
|
14
|
539
|
|
|
|
|
1816
|
my $subclass = $class->_load_subclass(); |
15
|
|
|
|
|
|
|
|
16
|
539
|
|
|
|
|
2199
|
for my $meth ( $subclass->Methods() ) |
17
|
|
|
|
|
|
|
{ |
18
|
539
|
|
|
|
|
1640
|
my $tz = $subclass->$meth(); |
19
|
|
|
|
|
|
|
|
20
|
539
|
50
|
|
|
|
2674
|
return $tz if $tz; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
0
|
die "Cannot determine local time zone\n"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
# Stolen from File::Spec. My theory is that other folks can write |
28
|
|
|
|
|
|
|
# the non-existent modules if they feel a need, and release them |
29
|
|
|
|
|
|
|
# to CPAN separately. |
30
|
|
|
|
|
|
|
my %subclass = ( MSWin32 => 'Win32', |
31
|
|
|
|
|
|
|
VMS => 'VMS', |
32
|
|
|
|
|
|
|
MacOS => 'Mac', |
33
|
|
|
|
|
|
|
os2 => 'OS2', |
34
|
|
|
|
|
|
|
epoc => 'Epoc', |
35
|
|
|
|
|
|
|
NetWare => 'Win32', |
36
|
|
|
|
|
|
|
symbian => 'Win32', |
37
|
|
|
|
|
|
|
dos => 'OS2', |
38
|
|
|
|
|
|
|
cygwin => 'Unix', |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _load_subclass |
42
|
|
|
|
|
|
|
{ |
43
|
540
|
|
|
540
|
|
1908
|
my $class = shift; |
44
|
|
|
|
|
|
|
|
45
|
540
|
|
50
|
|
|
6513
|
my $subclass = $class . '::' . ( shift || $subclass{ $^O } || 'Unix' ); |
46
|
|
|
|
|
|
|
|
47
|
540
|
50
|
|
|
|
8037
|
return $subclass if $subclass->can('Methods'); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
eval "use $subclass"; |
50
|
0
|
0
|
|
|
|
0
|
if ( my $e = $@ ) |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
0
|
|
|
|
0
|
if ( $e =~ /locate/ ) |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
|
|
0
|
$subclass = $class . '::' . 'Unix'; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
eval "use $subclass"; |
57
|
0
|
0
|
|
|
|
0
|
die $@ if $@; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else |
60
|
|
|
|
|
|
|
{ |
61
|
0
|
|
|
|
|
0
|
die $e; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
0
|
return $subclass; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub FromEnv |
70
|
|
|
|
|
|
|
{ |
71
|
543
|
|
|
543
|
1
|
8680
|
my $class = shift; |
72
|
|
|
|
|
|
|
|
73
|
543
|
|
|
|
|
1903
|
foreach my $var ( $class->EnvVars() ) |
74
|
|
|
|
|
|
|
{ |
75
|
543
|
100
|
|
|
|
2552
|
if ( $class->_IsValidName( $ENV{$var} ) ) |
76
|
|
|
|
|
|
|
{ |
77
|
542
|
|
|
|
|
4589
|
my $tz; |
78
|
|
|
|
|
|
|
{ |
79
|
542
|
|
|
|
|
650
|
local $@; |
|
542
|
|
|
|
|
1578
|
|
80
|
542
|
|
|
|
|
916
|
$tz = eval { DateTimeX::Lite::TimeZone->load( name => $ENV{$var} ) }; |
|
542
|
|
|
|
|
2972
|
|
81
|
|
|
|
|
|
|
} |
82
|
542
|
100
|
|
|
|
3325
|
return $tz if $tz; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
3
|
|
|
|
|
14
|
return; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _IsValidName |
90
|
|
|
|
|
|
|
{ |
91
|
543
|
|
|
543
|
|
656
|
shift; |
92
|
|
|
|
|
|
|
|
93
|
543
|
50
|
|
|
|
1706
|
return 0 unless defined $_[0]; |
94
|
543
|
50
|
|
|
|
1524
|
return 0 if $_[0] eq 'local'; |
95
|
|
|
|
|
|
|
|
96
|
543
|
|
|
|
|
3681
|
return $_[0] =~ m{^[\w/\-\+]+$}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |