| 1 | package DateTimeX::Lite::TimeZone; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 56 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 56 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 56 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 56 | ▶ | use DateTimeX::Lite::TimeZone::Catalog; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 56 | ▶ | use DateTimeX::Lite::TimeZone::Floating; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 56 | ▶ | use DateTimeX::Lite::TimeZone::Local; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 56 | ▶ | use DateTimeX::Lite::TimeZone::OffsetOnly; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 56 | ▶ | use DateTimeX::Lite::TimeZone::UTC; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 56 | ▶ | use DateTimeX::Lite::OlsonDB; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 56 | ▶ | use File::ShareDir qw(dist_file); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 56 | our %CachedTimeZones; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # the offsets for each span element | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 56 | ▶ | use constant UTC_START => 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 56 | ▶ | use constant UTC_END => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 56 | ▶ | use constant LOCAL_START => 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 56 | ▶ | use constant LOCAL_END => 3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 56 | ▶ | use constant OFFSET => 4; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 56 | ▶ | use constant IS_DST => 5; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 56 | ▶ | use constant SHORT_NAME => 6; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 56 | my %SpecialName = map { $_ => 1 } qw( EST MST HST CET EET MET WET EST5EDT CST6CDT MST7MDT PST8PDT ); | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 12893 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=18 SCAR=29.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 12893 | my ($class, %p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 12893 | my $name = $p{name}; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 12893 | my $conf; | |||||||||||||||||||||||||||||||||||||||||
| 32 | my $zone; | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 12893 | ▶ | if (defined $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 12892 | my $links = \%DateTimeX::Lite::TimeZone::Catalog::LINKS; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 12892 | ▶ | if ( exists $links->{ $name } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 276 | $name = $links->{ $name }; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } elsif ( exists $links->{ uc $name } ) { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $name = $links->{ uc $name }; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 12893 | ▶ | if (defined $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 12892 | ▶ | return $CachedTimeZones{$name} if $CachedTimeZones{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 1033 | ▶ | unless ( $name =~ m,/, || $SpecialName{ $name }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$name =~ m[/] or $SpecialName{$name}
MC/DC100%2/2
$name =~ m[/] or $SpecialName{$name}
$name =~ m[/]
$SpecialName{$name}
Truth table100%3/3
A or B
A= $name =~ m[/]B= $SpecialName{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 90 | ▶ | if ( $name eq 'floating' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 26 | return $CachedTimeZones{$name} = DateTimeX::Lite::TimeZone::Floating->new; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 64 | ▶ | if ( $name eq 'local' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | return $CachedTimeZones{$name} = DateTimeX::Lite::TimeZone::Local->TimeZone(); | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 63 | ▶ | if ( $name eq 'UTC' || $name eq 'Z' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$name eq "UTC" or $name eq "Z"
MC/DC100%2/2
$name eq "UTC" or $name eq "Z"
$name eq "UTC"
$name eq "Z"
Truth table100%3/3
A or B
A= $name eq "UTC"B= $name eq "Z"
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 39 | return $CachedTimeZones{$name} = DateTimeX::Lite::TimeZone::UTC->new; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 24 | return $CachedTimeZones{$name} = DateTimeX::Lite::TimeZone::OffsetOnly->new( offset => $name ); | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 943 | $conf = _load_time_zone($name); | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 944 | ▶ | if (! $conf) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | ▶ | my $x = $ENV{DATETIMEX_LITE_DEBUG} ? \&Carp::confess : \&Carp::croak ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 5 | ▶ | $x->( "The timezone '" . ($p{name} || 'undef') . "' could not be loaded, or is an invalid name.\n" ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$p{'name'} || 'undef'
MC/DC100%1/1
$p{'name'} || 'undef'
$p{'name'}
Truth table100%2/2
A
A= $p{'name'}
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 939 | $zone = $class->new(%$conf); | |||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 939 | ▶ | if ( $zone->is_olson() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | my $object_version = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | $zone->can('olson_version') | ||||||||||||||||||||||||||||||||||||||||||
| 71 | ? $zone->olson_version() | ||||||||||||||||||||||||||||||||||||||||||
| 72 | : 'unknown'; | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $catalog_version = DateTimeX::Lite::TimeZone::Catalog->OlsonVersion(); | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ( $object_version ne $catalog_version ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | warn "Loaded $name, which is from an older version ($object_version) of the Olson database than this installation of DateTimeX::Lite::TimeZone ($catalog_version).\n"; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 939 | $CachedTimeZones{$name} = $zone; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 939 | return $zone; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 939 | ▶ | sub new { my $class = shift; bless { @_ }, $class } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 943 | ▶ | sub _load_time_zone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_time_zone: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 943 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 943 | my $file = "$name.dat"; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 943 | $file =~ s/-/_/g; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | # Quietly fail here, so we can let the proceeding section croak for us | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 943 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 94 | 943 | $file = dist_file( 'DateTimeX-Lite', "DateTimeX/Lite/TimeZone/$file"); | |||||||||||||||||||||||||||||||||||||||||
| 95 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 943 | ▶ | return $file ? do $file : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 20 | ▶ | sub rules { $_[0]->{rules} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rules: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 21 | ▶ | sub max_year { $_[0]->{max_year} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_year: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 1246 | ▶ | sub last_offset { $_[0]->{last_offset} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_offset: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 1205 | ▶ | sub last_observance { $_[0]->{last_observance} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_observance: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 940 | ▶ | sub is_olson { $_[0]->{is_olson} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_olson: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | sub is_dst_for_datetime | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 56 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_dst_for_datetime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 56 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 56 | my $span = $self->_span_for_datetime( 'utc', $_[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 56 | return $span->[IS_DST]; | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | sub offset_for_datetime | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 417 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset_for_datetime: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 417 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 417 | my $span = $self->_span_for_datetime( 'utc', $_[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 417 | return $span->[OFFSET]; | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | sub offset_for_local_datetime | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 269 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset_for_local_datetime: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 269 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 269 | my $span = $self->_span_for_datetime( 'local', $_[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 261 | return $span->[OFFSET]; | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | sub short_name_for_datetime | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 56 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
short_name_for_datetime: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 56 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 56 | my $span = $self->_span_for_datetime( 'utc', $_[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 56 | return $span->[SHORT_NAME]; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | sub _span_for_datetime | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 798 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_span_for_datetime: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 798 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 798 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 798 | my $dt = shift; | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 798 | my $method = $type . '_rd_as_seconds'; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 798 | ▶ | my $end = $type eq 'utc' ? UTC_END : LOCAL_END; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 798 | my $span; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 798 | my $seconds = $dt->$method(); | |||||||||||||||||||||||||||||||||||||||||
| 154 | 798 | ▶ | if ( $seconds < $self->max_span->[$end] ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 779 | $span = $self->_spans_binary_search( $type, $seconds ); | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | else | ||||||||||||||||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 19 | my $until_year = $dt->utc_year + 1; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 19 | $span = $self->_generate_spans_until_match( $until_year, $seconds, $type ); | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | # This means someone gave a local time that doesn't exist | ||||||||||||||||||||||||||||||||||||||||||
| 165 | # (like during a transition into savings time) | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 798 | ▶ | unless ( defined $span ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 8 | my $err = 'Invalid local time for date'; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 8 | ▶ | $err .= ' ' . $dt->iso8601 if $type eq 'utc'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 8 | $err .= " in time zone: " . $self->name; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 8 | $err .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 8 | die $err; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 790 | return $span; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | sub _spans_binary_search | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 779 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_spans_binary_search: called CC=17 SCAR=28.7
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 779 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 779 | my ( $type, $seconds ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 779 | my ( $start, $end ) = _keys_for_type($type); | |||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 779 | my $min = 0; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 779 | my $max = scalar @{ $self->{spans} } + 1; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 779 | my $i = int( $max / 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 189 | # special case for when there are only 2 spans | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 779 | ▶ | $i++ if $max % 2 && $max != 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$max % 2 and $max != 3
MC/DC100%2/2
$max % 2 and $max != 3
$max % 2
$max != 3
Truth table100%3/3
A and B
A= $max % 2B= $max != 3
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 779 | ▶ | $i = 0 if @{ $self->{spans} } == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 779 | while (1) | |||||||||||||||||||||||||||||||||||||||||
| 195 | { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 5223 | my $current = $self->{spans}[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 5223 | ▶ | if ( $seconds < $current->[$start] ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | { | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 1969 | $max = $i; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 1969 | my $c = int( ( $i - $min ) / 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 201 | 1969 | ▶ | $c ||= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$c ||= 1
MC/DC100%1/1
$c ||= 1
$c
Truth table100%2/2
A
A= $c
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 1969 | $i -= $c; | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 1969 | ▶ | return if $i < $min; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | elsif ( $seconds >= $current->[$end] ) | ||||||||||||||||||||||||||||||||||||||||||
| 208 | { | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 2482 | $min = $i; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 2482 | my $c = int( ( $max - $i ) / 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 211 | 2482 | ▶ | $c ||= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$c ||= 1
MC/DC100%1/1
$c ||= 1
$c
Truth table100%2/2
A
A= $c
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 2482 | $i += $c; | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 2482 | ▶ | return if $i >= $max; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | else | ||||||||||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | # Special case for overlapping ranges because of DST and | ||||||||||||||||||||||||||||||||||||||||||
| 220 | # other weirdness (like Alaska's change when bought from | ||||||||||||||||||||||||||||||||||||||||||
| 221 | # Russia by the US). Always prefer latest span. | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 772 | ▶ | if ( $current->[IS_DST] && $type eq 'local' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$current->[5] and $type eq "local"
MC/DC100%2/2
$current->[5] and $type eq "local"
$current->[5]
$type eq "local"
Truth table100%3/3
A and B
A= $current->[5]B= $type eq "local"
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 103 | my $next = $self->{spans}[$i + 1]; | |||||||||||||||||||||||||||||||||||||||||
| 225 | # Sometimes we will get here and the span we're | ||||||||||||||||||||||||||||||||||||||||||
| 226 | # looking at is the last that's been generated so far. | ||||||||||||||||||||||||||||||||||||||||||
| 227 | # We need to try to generate one more or else we run | ||||||||||||||||||||||||||||||||||||||||||
| 228 | # out. | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 103 | ▶ | $next ||= $self->_generate_next_span; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$next ||= $self->_generate_next_span
MC/DC0%0/2
$next ||= $self->_generate_next_span
$next
$self->_generate_next_span
Truth table66%2/3
A ||= B
A= $nextB= $self->_generate_next_span
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 103 | ▶ | die "No next span in $self->{max_year}" unless defined $next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 103 | ▶ | if ( ( ! $next->[IS_DST] ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not $next->[5] and $next->[$start] <= $seconds and $seconds <= $next->[$end]
not $next->[5] and $next->[$start] <= $seconds
MC/DC0%0/3
not $next->[5] and $next->[$start] <= $seconds and $seconds <= $next->[$end]
not $next->[5]
$next->[$start] <= $seconds
$seconds <= $next->[$end]
Truth table50%2/4
not(A) and B and C
A= not $next->[5]B= $next->[$start] <= $secondsC= $seconds <= $next->[$end]
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | && $next->[$start] <= $seconds | ||||||||||||||||||||||||||||||||||||||||||
| 235 | && $seconds <= $next->[$end] | ||||||||||||||||||||||||||||||||||||||||||
| 236 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 237 | { | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return $next; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 772 | return $current; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | sub _generate_next_span | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_next_span: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | my $last_idx = $#{ $self->{spans} }; | |||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | my $max_span = $self->max_span; | |||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | # Kind of a hack, but AFAIK there are no zones where it takes | ||||||||||||||||||||||||||||||||||||||||||
| 256 | # _more_ than a year for a _future_ time zone change to occur, so | ||||||||||||||||||||||||||||||||||||||||||
| 257 | # by looking two years out we can ensure that we will find at | ||||||||||||||||||||||||||||||||||||||||||
| 258 | # least one more span. Of course, I will no doubt be proved wrong | ||||||||||||||||||||||||||||||||||||||||||
| 259 | # and this will cause errors. | ||||||||||||||||||||||||||||||||||||||||||
| 260 | $self->_generate_spans_until_match | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | ( $self->{max_year} + 2, $max_span->[UTC_END] + ( 366 * 86400 ), 'utc' ); | |||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | return $self->{spans}[ $last_idx + 1 ]; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | sub _generate_spans_until_match | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 20 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_spans_until_match: called CC=11 SCAR=24.1
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 20 | my $generate_until_year = shift; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 20 | my $seconds = shift; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 20 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 20 | my @changes; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 20 | my @rules = @{ $self->rules }; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 20 | foreach my $year ( $self->max_year .. $generate_until_year ) | |||||||||||||||||||||||||||||||||||||||||
| 276 | { | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 623 | ▶ | for ( my $x = 0; $x < @rules; $x++ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | { | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 1246 | my $last_offset_from_std; | |||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 1246 | ▶ | if ( @rules == 2 ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | { | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 1246 | ▶ | $last_offset_from_std = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | $x ? $rules[0]->offset_from_std : $rules[1]->offset_from_std; | ||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | elsif ( @rules == 1 ) | ||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $last_offset_from_std = $rules[0]->offset_from_std; | |||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | else | ||||||||||||||||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $count = scalar @rules; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | die "Cannot generate future changes for zone with $count infinite rules\n"; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 1246 | my $rule = $rules[$x]; | |||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 1246 | my $next = | |||||||||||||||||||||||||||||||||||||||||
| 299 | $rule->utc_start_datetime_for_year | ||||||||||||||||||||||||||||||||||||||||||
| 300 | ( $year, $self->last_offset, $last_offset_from_std ); | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | # don't bother with changes we've seen already | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 1246 | ▶ | next if $next->utc_rd_as_seconds < $self->max_span->[UTC_END]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 1205 | my $last_observance = $self->last_observance; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 1205 | push @changes, | |||||||||||||||||||||||||||||||||||||||||
| 307 | DateTimeX::Lite::OlsonDB::Change->new | ||||||||||||||||||||||||||||||||||||||||||
| 308 | ( type => 'rule', | ||||||||||||||||||||||||||||||||||||||||||
| 309 | utc_start_datetime => $next, | ||||||||||||||||||||||||||||||||||||||||||
| 310 | local_start_datetime => | ||||||||||||||||||||||||||||||||||||||||||
| 311 | $next + | ||||||||||||||||||||||||||||||||||||||||||
| 312 | DateTimeX::Lite::Duration->new | ||||||||||||||||||||||||||||||||||||||||||
| 313 | ( seconds => $last_observance->total_offset + | ||||||||||||||||||||||||||||||||||||||||||
| 314 | $rule->offset_from_std ), | ||||||||||||||||||||||||||||||||||||||||||
| 315 | short_name => | ||||||||||||||||||||||||||||||||||||||||||
| 316 | sprintf( $last_observance->format, $rule->letter ), | ||||||||||||||||||||||||||||||||||||||||||
| 317 | observance => $last_observance, | ||||||||||||||||||||||||||||||||||||||||||
| 318 | rule => $rule, | ||||||||||||||||||||||||||||||||||||||||||
| 319 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 20 | $self->{max_year} = $generate_until_year; | |||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 20 | my @sorted = sort { $a->utc_start_datetime <=> $b->utc_start_datetime } @changes; | |||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 20 | my ( $start, $end ) = _keys_for_type($type); | |||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 20 | my $match; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 20 | ▶ | for ( my $x = 1; $x < @sorted; $x++ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | { | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 1185 | ▶ | my $last_total_offset = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | $x == 1 ? $self->max_span->[OFFSET] : $sorted[ $x - 2 ]->total_offset; | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 1185 | my $span = | |||||||||||||||||||||||||||||||||||||||||
| 336 | DateTimeX::Lite::OlsonDB::Change::two_changes_as_span | ||||||||||||||||||||||||||||||||||||||||||
| 337 | ( @sorted[ $x - 1, $x ], $last_total_offset ); | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 1185 | $span = _span_as_array($span); | |||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 1185 | push @{ $self->{spans} }, $span; | |||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 1185 | ▶ | $match = $span | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$seconds >= $span->[$start] and $seconds < $span->[$end]
MC/DC100%2/2
$seconds >= $span->[$start] and $seconds < $span->[$end]
$seconds >= $span->[$start]
$seconds < $span->[$end]
Truth table100%3/3
A and B
A= $seconds >= $span->[$start]B= $seconds < $span->[$end]
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | if $seconds >= $span->[$start] && $seconds < $span->[$end]; | ||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 20 | return $match; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 2065 | ▶ | sub max_span { $_[0]->{spans}[-1] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_span: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | sub _keys_for_type | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 799 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_keys_for_type: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 799 | ▶ | $_[0] eq 'utc' ? ( UTC_START, UTC_END ) : ( LOCAL_START, LOCAL_END ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | sub _span_as_array | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 1185 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_span_as_array: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 1185 | [ @{ $_[0] }{ qw( utc_start utc_end local_start local_end offset is_dst short_name ) } ]; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 34550 | ▶ | sub is_floating { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_floating: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 772 | ▶ | sub is_utc { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_utc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 55 | ▶ | sub has_dst_changes { $_[0]->{has_dst_changes} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_dst_changes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 1109 | ▶ | sub name { $_[0]->{name} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub category { (split /\//, $_[0]->{name}, 2)[0] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
category: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | sub is_valid_name | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_name: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 13 | my $tz; | |||||||||||||||||||||||||||||||||||||||||
| 374 | { | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 13 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 13 | $tz = eval { $_[0]->load( name => $_[1] ) }; | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 13 | ▶ | return $tz && $tz->isa('DateTimeX::Lite::TimeZone') ? 1 : 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tz and $tz->isa("DateTimeX::Lite::TimeZone")
MC/DC50%1/2
$tz and $tz->isa("DateTimeX::Lite::TimeZone")
$tz
$tz->isa("DateTimeX::Lite::TimeZone")
Truth table66%2/3
A and B
A= $tzB= $tz->isa("DateTimeX::Lite::TimeZone")
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | # | ||||||||||||||||||||||||||||||||||||||||||
| 383 | # Functions | ||||||||||||||||||||||||||||||||||||||||||
| 384 | # | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 224 | ▶ | sub offset_as_seconds { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset_as_seconds: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | { | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 224 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 224 | ▶ | shift if eval { $_[0]->isa('DateTimeX::Lite::TimeZone') }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 224 | DateTimeX::Lite::Util::offset_as_seconds(@_); | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 74 | ▶ | sub offset_as_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset_as_string: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | { | ||||||||||||||||||||||||||||||||||||||||||
| 395 | 74 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 74 | ▶ | shift if eval { $_[0]->isa('DateTimeX::Lite::TimeZone') }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 74 | DateTimeX::Lite::Util::offset_as_string(@_); | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | # These methods all operate on data contained in the DateTime/TimeZone/Catalog.pm file. | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 4 | ▶ | sub all_names { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_names: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 4 | ▶ | return wantarray ? @DateTimeX::Lite::TimeZone::Catalog::ALL : [@DateTimeX::Lite::TimeZone::Catalog::ALL]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 2 | ▶ | sub categories { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
categories: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | return wantarray | ||||||||||||||||||||||||||||||||||||||||||
| 409 | ? @DateTimeX::Lite::TimeZone::Catalog::CATEGORY_NAMES | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 2 | ▶ | : [@DateTimeX::Lite::TimeZone::Catalog::CATEGORY_NAMES]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | sub links | ||||||||||||||||||||||||||||||||||||||||||
| 414 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
links: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | return | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 5 | ▶ | wantarray ? %DateTimeX::Lite::TimeZone::Catalog::LINKS : {%DateTimeX::Lite::TimeZone::Catalog::LINKS}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | sub names_in_category | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names_in_category: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | ▶ | shift if $_[0]->isa('DateTimeX::Lite::TimeZone'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 3 | ▶ | return unless exists $DateTimeX::Lite::TimeZone::Catalog::CATEGORIES{ $_[0] }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | return | ||||||||||||||||||||||||||||||||||||||||||
| 425 | wantarray | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 2 | ? @{ $DateTimeX::Lite::TimeZone::Catalog::CATEGORIES{ $_[0] } } | |||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | ▶ | : [ $DateTimeX::Lite::TimeZone::Catalog::CATEGORIES{ $_[0] } ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | sub countries | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
countries: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | wantarray | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 1 | ▶ | ? ( sort keys %DateTimeX::Lite::TimeZone::Catalog::ZONES_BY_COUNTRY ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | : [ sort keys %DateTimeX::Lite::TimeZone::Catalog::ZONES_BY_COUNTRY ]; | ||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | sub names_in_country | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names_in_country: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 5 | ▶ | shift if $_[0]->isa('DateTimeX::Lite::TimeZone'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 5 | ▶ | return unless exists $DateTimeX::Lite::TimeZone::Catalog::ZONES_BY_COUNTRY{ lc $_[0] }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | return | ||||||||||||||||||||||||||||||||||||||||||
| 444 | wantarray | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 4 | ? @{ $DateTimeX::Lite::TimeZone::Catalog::ZONES_BY_COUNTRY{ lc $_[0] } } | |||||||||||||||||||||||||||||||||||||||||
| 446 | 5 | ▶ | : $DateTimeX::Lite::TimeZone::Catalog::ZONES_BY_COUNTRY{ lc $_[0] }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | 56 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | __END__ | ||||||||||||||||||||||||||||||||||||||||||