| 1 | package DateTime::TimeZone::Local::hpux; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # Debugging flags, used in the testsuite | ||||||||||||||||||||||||||||
| 7 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | defined &SKIP_ETC_TIMEZONE or *SKIP_ETC_TIMEZONE = sub () { 0 }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | defined &SKIP_JAVA or *SKIP_JAVA = sub () { 0 }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use base 'DateTime::TimeZone::Local'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use DateTime::TimeZone::HPUX; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub Methods | ||||||||||||||||||||||||||||
| 18 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
Methods: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 1 | qw( _FromEnv _FromEtcTIMEZONE _FromJava ) | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # TODO Build the full timezone database from /usr/lib/tztab | ||||||||||||||||||||||||||||
| 23 | sub _FromEnv | ||||||||||||||||||||||||||||
| 24 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_FromEnv: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | return unless exists $ENV{TZ}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | DateTime::TimeZone::HPUX::_hpux_to_olson($ENV{TZ}) | ||||||||||||||||||||||||||||
| 27 | 1 | } | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | sub _FromEtcTIMEZONE | ||||||||||||||||||||||||||||
| 30 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_FromEtcTIMEZONE: called CC=6 SCAR=31.5
| |||||||||||||||||||||||||||||
| 31 | 1 | return if SKIP_ETC_TIMEZONE; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | my $tz_file = '/etc/TIMEZONE'; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | return unless -f $tz_file && -r _; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-f $tz_file and -r _
MC/DC0%0/2
-f $tz_file and -r _
-f $tz_file
-r _
Truth table33%1/3
A and B
A= -f $tz_fileB= -r _
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | local *TZ; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | open TZ, "<$tz_file" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | or die "Cannot read $tz_file: $!"; | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | my $name; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | while ( defined( $name = <TZ> ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ( $name =~ /\A\s*TZ\s*=\s*(\S+)/ ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | { | ||||||||||||||||||||||||||||
| 46 | 0 | $name = $1; | |||||||||||||||||||||||||||
| 47 | 0 | last; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | 0 | close TZ; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | DateTime::TimeZone::HPUX::_hpux_to_olson($name) | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # Retrieve the default timezone using Java (java.util.TimeZone.getDefault()) | ||||||||||||||||||||||||||||
| 56 | sub _FromJava | ||||||||||||||||||||||||||||
| 57 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_FromJava: called CC=2 SCAR=8.5
| |||||||||||||||||||||||||||||
| 58 | 1 | return if SKIP_JAVA; | |||||||||||||||||||||||||||
| 59 | 1 | warn('Retrieving default timezone using Java (SLOOOOOW)... You should instead set $ENV{TZ}'); | |||||||||||||||||||||||||||
| 60 | 1 | my $tz_name = DateTime::TimeZone::HPUX::_olson_from_java(); | |||||||||||||||||||||||||||
| 61 | 1 | ▶ | return unless defined $tz_name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | # Build a DT::TZ object from the name returned by Java | ||||||||||||||||||||||||||||
| 64 | 0 | local $@; | |||||||||||||||||||||||||||
| 65 | 0 | return eval { DateTime::TimeZone->new(name => $tz_name) }; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 3 | 1; | |||||||||||||||||||||||||||
| 70 | __END__ | ||||||||||||||||||||||||||||