| 1 | package DateTime::Fiscal::Retail454; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 7 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 7 | our $R454DEBUG = 0; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use DateTime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use base qw(DateTime); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 7 | my $pkg = __PACKAGE__; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 7 | my @periodmonths = qw( | |||||||||||||||||||||||||||
| 18 | February | ||||||||||||||||||||||||||||
| 19 | March | ||||||||||||||||||||||||||||
| 20 | April | ||||||||||||||||||||||||||||
| 21 | May | ||||||||||||||||||||||||||||
| 22 | June | ||||||||||||||||||||||||||||
| 23 | July | ||||||||||||||||||||||||||||
| 24 | August | ||||||||||||||||||||||||||||
| 25 | September | ||||||||||||||||||||||||||||
| 26 | October | ||||||||||||||||||||||||||||
| 27 | November | ||||||||||||||||||||||||||||
| 28 | December | ||||||||||||||||||||||||||||
| 29 | January | ||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # This code ref builds a cache that can be used as long as the value in | ||||||||||||||||||||||||||||
| 33 | # the _R454_basedate attribute remains unchanged. | ||||||||||||||||||||||||||||
| 34 | 856 | ▶ | my $_r454_build_periods = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 35 | 856 | my $self = shift; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | return | ||||||||||||||||||||||||||||
| 38 | 856 | ▶ | if ref($self->{_R454_periods}) && $self->{_R454_basedate} eq $self->ymd; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $self->{"_R454_periods"} and $self->{"_R454_basedate"} eq $self->ymd
MC/DC50%1/2
ref $self->{"_R454_periods"} and $self->{"_R454_basedate"} eq $self->ymd
ref $self->{"_R454_periods"}
$self->{"_R454_basedate"} eq $self->ymd
Truth table66%2/3
A and B
A= ref $self->{"_R454_periods"}B= $self->{"_R454_basedate"} eq $self->ymd
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 17 | my @pweeks = (0, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5, 4); | |||||||||||||||||||||||||||
| 41 | 17 | ▶ | $pweeks[$#pweeks] = 5 if $self->is_r454_leap_year; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 17 | my $pdata = {}; | |||||||||||||||||||||||||||
| 44 | 17 | my $pstart = $pkg->_454_start($self->r454_year); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 17 | for (1 .. 12) { | |||||||||||||||||||||||||||
| 47 | 204 | $pdata->{$_} = { | |||||||||||||||||||||||||||
| 48 | pstart => $pstart->clone, | ||||||||||||||||||||||||||||
| 49 | weeks => $pweeks[$_], | ||||||||||||||||||||||||||||
| 50 | r454year => $self->r454_year, | ||||||||||||||||||||||||||||
| 51 | month => $periodmonths[$_ - 1] | ||||||||||||||||||||||||||||
| 52 | }; | ||||||||||||||||||||||||||||
| 53 | 204 | my $pend = | |||||||||||||||||||||||||||
| 54 | $pstart->clone->add(weeks => $pweeks[$_])->subtract(seconds => 1); | ||||||||||||||||||||||||||||
| 55 | 204 | $pdata->{$_}->{pend} = $pend; | |||||||||||||||||||||||||||
| 56 | 204 | my $ppub = $pend->clone->truncate(to => 'day')->add(days => 5); | |||||||||||||||||||||||||||
| 57 | 204 | $pdata->{$_}->{ppub} = $ppub; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 204 | $pstart = $pstart->clone->add(weeks => $pweeks[$_]); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 17 | $self->{_R454_periods} = $pdata; | |||||||||||||||||||||||||||
| 63 | 17 | $self->{_R454_basedate} = $self->ymd; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 7 | }; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # this code ref is used with versions of DateTime prior to 0.64 | ||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $_454_allocate = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | $self->{_R454_year} = undef; | |||||||||||||||||||||||||||
| 72 | 0 | $self->{_R454_periods} = undef; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | return; | |||||||||||||||||||||||||||
| 75 | 7 | }; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # this override is required for versions of DateTime starting with 0.64 | ||||||||||||||||||||||||||||
| 78 | # and serves the same purpose as the above code reference, but in a | ||||||||||||||||||||||||||||
| 79 | # much nicer way. | ||||||||||||||||||||||||||||
| 80 | sub _new | ||||||||||||||||||||||||||||
| 81 | 1368 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_new: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 82 | 1368 | my $proto = shift; | |||||||||||||||||||||||||||
| 83 | 1368 | my %params = @_; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 1368 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 1368 | my $self = $class->SUPER::_new(%params); | |||||||||||||||||||||||||||
| 88 | 1368 | $self->{_R454_year} = undef; | |||||||||||||||||||||||||||
| 89 | 1368 | $self->{_R454_periods} = undef; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 1368 | return $self; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | sub _454_start | ||||||||||||||||||||||||||||
| 95 | 150 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_454_start: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 96 | 150 | my $proto = shift; | |||||||||||||||||||||||||||
| 97 | 150 | my $cyr = shift; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 150 | my ($package, $filename, $line) = caller; | |||||||||||||||||||||||||||
| 100 | 150 | ▶ | confess "FORBIDDEN private method call" unless $package->isa($pkg); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 149 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition66%2/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table66%2/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # my $r454tmp = $pkg->SUPER::new( year => $cyr, month => 1, day => 31 ); | ||||||||||||||||||||||||||||
| 105 | 149 | my $r454tmp = $class->SUPER::new(year => $cyr, month => 1, day => 31); | |||||||||||||||||||||||||||
| 106 | 149 | my $jan31dow = $r454tmp->dow; | |||||||||||||||||||||||||||
| 107 | 149 | ▶ | if ($jan31dow < 3) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 108 | 43 | $r454tmp->subtract(days => $jan31dow); | |||||||||||||||||||||||||||
| 109 | } elsif ($jan31dow < 7) { | ||||||||||||||||||||||||||||
| 110 | 94 | $r454tmp->add(days => (7 - $jan31dow)); | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 149 | return $r454tmp; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | sub from_r454year | ||||||||||||||||||||||||||||
| 117 | 18 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
from_r454year: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||
| 118 | 18 | my $proto = shift; | |||||||||||||||||||||||||||
| 119 | 18 | my %params = @_; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | croak "Mandatory parameter 'r454year' missing" | ||||||||||||||||||||||||||||
| 122 | 18 | ▶ | unless defined($params{r454year}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 18 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | #return( bless $pkg->_454_start($params{r454year}), $proto ) | ||||||||||||||||||||||||||||
| 127 | 18 | return $class->_454_start($params{r454year}); | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | # These have to be overloaded here in order to properly setup any attributes | ||||||||||||||||||||||||||||
| 131 | # used by this module. In addition, 'from_day_of_year' has to be here | ||||||||||||||||||||||||||||
| 132 | # because it does not ever call the normal 'new' constructor. | ||||||||||||||||||||||||||||
| 133 | # | ||||||||||||||||||||||||||||
| 134 | # NOTE!!! | ||||||||||||||||||||||||||||
| 135 | # It appears that DateTime calls new any time a change is made to the object's | ||||||||||||||||||||||||||||
| 136 | # value, through actions such as date math or the 'set' functions. | ||||||||||||||||||||||||||||
| 137 | # OTOH, the object is left alone for any of the 'get' functions. | ||||||||||||||||||||||||||||
| 138 | # | ||||||||||||||||||||||||||||
| 139 | # Because of this, care must be taken to ensure a recursive loop isn't | ||||||||||||||||||||||||||||
| 140 | # created, hence the need for a seperate constructor for 'from_r454year'. | ||||||||||||||||||||||||||||
| 141 | # | ||||||||||||||||||||||||||||
| 142 | # NOTE!!! | ||||||||||||||||||||||||||||
| 143 | # The internals of DateTime have changed in version 0.64 which makes | ||||||||||||||||||||||||||||
| 144 | # sub-classing much easier. This code has been changed accordingly to | ||||||||||||||||||||||||||||
| 145 | # try to pick up which style is being used in DateTime. | ||||||||||||||||||||||||||||
| 146 | # | ||||||||||||||||||||||||||||
| 147 | # Even so, I am poking around under the hood and can be bit in the future. | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | sub new | ||||||||||||||||||||||||||||
| 150 | 1000 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||
| 151 | 1000 | my $proto = shift; | |||||||||||||||||||||||||||
| 152 | 1000 | my %params = @_; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 1000 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 1000 | my $self = $class->SUPER::new(%params); | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | # &{$_454_allocate}($self); | ||||||||||||||||||||||||||||
| 159 | 0 | ▶ | &{$_454_allocate}($self) unless exists($self->{_R454_year}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 1000 | return ($self); | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | # this override is needed because the constructor in earlier versions of | ||||||||||||||||||||||||||||
| 165 | # DateTime did not propagate sub-classing. | ||||||||||||||||||||||||||||
| 166 | sub from_day_of_year | ||||||||||||||||||||||||||||
| 167 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
from_day_of_year: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||
| 168 | 2 | my $proto = shift; | |||||||||||||||||||||||||||
| 169 | 2 | my %params = @_; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 2 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | # my $self = bless $pkg->SUPER::from_day_of_year(%params), $proto; | ||||||||||||||||||||||||||||
| 174 | 2 | my $self = $class->SUPER::from_day_of_year(%params); | |||||||||||||||||||||||||||
| 175 | 2 | ▶ | bless $self, $class unless ref($self) eq $class; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | # &{$_454_allocate}($self); | ||||||||||||||||||||||||||||
| 178 | 0 | ▶ | &{$_454_allocate}($self) unless exists($self->{_R454_year}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 2 | return ($self); | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | sub r454_year | ||||||||||||||||||||||||||||
| 184 | 498 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
r454_year: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 185 | 498 | my $self = shift; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 498 | ▶ | if (!defined($self->{_R454_year})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 21 | my $r454tmp = $pkg->_454_start($self->year); | |||||||||||||||||||||||||||
| 189 | $self->{_R454_year} = | ||||||||||||||||||||||||||||
| 190 | 21 | ▶ | $r454tmp > $self ? $self->year - 1 : $r454tmp->year; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 498 | return ($self->{_R454_year}); | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | sub is_r454_leap_year | ||||||||||||||||||||||||||||
| 197 | 31 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
is_r454_leap_year: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 198 | 31 | my $self = shift; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 31 | my $tmpnext = $pkg->_454_start($self->r454_year)->add(days => 364); | |||||||||||||||||||||||||||
| 201 | 31 | my $realnext = $pkg->_454_start($self->r454_year + 1); | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 31 | ▶ | return ($realnext > $tmpnext ? 1 : 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | sub r454_start | ||||||||||||||||||||||||||||
| 207 | 16 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
r454_start: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 208 | 16 | my $self = shift; | |||||||||||||||||||||||||||
| 209 | 16 | my %params = @_; | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 16 | ▶ | my $asobj = (defined($params{as_obj}) ? $params{as_obj} : 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 16 | my $r454start = $pkg->_454_start($self->r454_year); | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 16 | ▶ | return ($asobj ? $r454start : "" . $r454start); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | sub r454_end | ||||||||||||||||||||||||||||
| 219 | 14 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
r454_end: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||
| 220 | 14 | my $self = shift; | |||||||||||||||||||||||||||
| 221 | 14 | my %params = @_; | |||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 14 | ▶ | my $asobj = (defined($params{as_obj}) ? $params{as_obj} : 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 14 | my $r454end = | |||||||||||||||||||||||||||
| 226 | $pkg->_454_start($self->r454_year + 1)->subtract(seconds => 1); | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 14 | ▶ | return ($asobj ? $r454end : "" . $r454end); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | sub r454_period | ||||||||||||||||||||||||||||
| 232 | 170 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
r454_period: called CC=15 SCAR=29.3
Pod
documented
| |||||||||||||||||||||||||||||
| 233 | 170 | my $self = shift; | |||||||||||||||||||||||||||
| 234 | 170 | my %params = @_; | |||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 170 | ▶ | my $asobj = defined($params{as_obj}) ? $params{as_obj} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 170 | ▶ | carp "objects requested in non-array context" if $asobj && !wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$asobj and not wantarray
MC/DC0%0/2
$asobj and not wantarray
$asobj
not wantarray
Truth table33%1/3
A and not(B)
A= $asobjB= not wantarray
| |||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 170 | ▶ | my $pnum = defined($params{period}) ? 0 + $params{period} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 170 | &{$_r454_build_periods}($self); | |||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 170 | ▶ | if (!$pnum) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 2 | $pnum = 1; | |||||||||||||||||||||||||||
| 245 | 2 | ▶ | while ($self->{_R454_periods}->{$pnum}->{pstart} < $self) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 20 | ▶ | last if $self->{_R454_periods}->{$pnum + 1}->{pstart} > $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 18 | ▶ | last if ++$pnum == 12; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | 170 | ▶ | croak "Invalid Period specified" unless $pnum > 0 && $pnum < 13; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pnum > 0 and $pnum < 13
MC/DC0%0/2
$pnum > 0 and $pnum < 13
$pnum > 0
$pnum < 13
Truth table33%1/3
A and B
A= $pnum > 0B= $pnum < 13
| |||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 170 | ▶ | return ($pnum) unless wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 168 | my $phash = $self->{_R454_periods}->{$pnum}; | |||||||||||||||||||||||||||
| 255 | my @pdata = ( | ||||||||||||||||||||||||||||
| 256 | $pnum, | ||||||||||||||||||||||||||||
| 257 | $phash->{weeks}, | ||||||||||||||||||||||||||||
| 258 | ($asobj ? $phash->{pstart}->clone : "" . $phash->{pstart}), | ||||||||||||||||||||||||||||
| 259 | ($asobj ? $phash->{pend}->clone : "" . $phash->{pend}), | ||||||||||||||||||||||||||||
| 260 | ($asobj ? $phash->{ppub}->clone : "" . $phash->{ppub}), | ||||||||||||||||||||||||||||
| 261 | $phash->{r454year} | ||||||||||||||||||||||||||||
| 262 | 168 | ▶ | ); | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 168 | return (@pdata); | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | sub r454_period_weeks | ||||||||||||||||||||||||||||
| 268 | 168 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
r454_period_weeks: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 269 | 168 | my $self = shift; | |||||||||||||||||||||||||||
| 270 | 168 | my %params = @_; | |||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | my $pnum = | ||||||||||||||||||||||||||||
| 273 | 168 | ▶ | defined($params{period}) ? 0 + $params{period} : $self->r454_period; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | 168 | ▶ | croak "Invalid Period specified" unless $pnum > 0 && $pnum < 13; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pnum > 0 and $pnum < 13
MC/DC0%0/2
$pnum > 0 and $pnum < 13
$pnum > 0
$pnum < 13
Truth table33%1/3
A and B
A= $pnum > 0B= $pnum < 13
| |||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 168 | &{$_r454_build_periods}($self); | |||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 168 | return ($self->{_R454_periods}->{$pnum}->{weeks}); | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | sub r454_period_start | ||||||||||||||||||||||||||||
| 282 | 170 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
r454_period_start: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||
| 283 | 170 | my $self = shift; | |||||||||||||||||||||||||||
| 284 | 170 | my %params = @_; | |||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 170 | ▶ | my $asobj = defined($params{as_obj}) ? $params{as_obj} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | my $pnum = | ||||||||||||||||||||||||||||
| 288 | 170 | ▶ | defined($params{period}) ? 0 + $params{period} : $self->r454_period; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | 170 | ▶ | croak "Invalid Period specified" unless $pnum > 0 && $pnum < 13; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pnum > 0 and $pnum < 13
MC/DC0%0/2
$pnum > 0 and $pnum < 13
$pnum > 0
$pnum < 13
Truth table33%1/3
A and B
A= $pnum > 0B= $pnum < 13
| |||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 170 | &{$_r454_build_periods}($self); | |||||||||||||||||||||||||||
| 292 | 170 | my $pobj = $self->{_R454_periods}->{$pnum}->{pstart}; | |||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 170 | ▶ | return ($asobj ? $pobj : "" . $pobj); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | sub r454_period_end | ||||||||||||||||||||||||||||
| 298 | 168 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
r454_period_end: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||
| 299 | 168 | my $self = shift; | |||||||||||||||||||||||||||
| 300 | 168 | my %params = @_; | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 168 | ▶ | my $asobj = defined($params{as_obj}) ? $params{as_obj} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 303 | my $pnum = | ||||||||||||||||||||||||||||
| 304 | 168 | ▶ | defined($params{period}) ? 0 + $params{period} : $self->r454_period; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 168 | ▶ | croak "Invalid Period specified" unless $pnum > 0 && $pnum < 13; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pnum > 0 and $pnum < 13
MC/DC0%0/2
$pnum > 0 and $pnum < 13
$pnum > 0
$pnum < 13
Truth table33%1/3
A and B
A= $pnum > 0B= $pnum < 13
| |||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 168 | &{$_r454_build_periods}($self); | |||||||||||||||||||||||||||
| 308 | 168 | my $pobj = $self->{_R454_periods}->{$pnum}->{pend}->clone; | |||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 168 | ▶ | return ($asobj ? $pobj : "" . $pobj); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | sub r454_period_publish | ||||||||||||||||||||||||||||
| 314 | 168 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
r454_period_publish: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||
| 315 | 168 | my $self = shift; | |||||||||||||||||||||||||||
| 316 | 168 | my %params = @_; | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 168 | ▶ | my $asobj = defined($params{as_obj}) ? $params{as_obj} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | my $pnum = | ||||||||||||||||||||||||||||
| 320 | 168 | ▶ | defined($params{period}) ? 0 + $params{period} : $self->r454_period; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 321 | 168 | ▶ | croak "Invalid Period specified" unless $pnum > 0 && $pnum < 13; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pnum > 0 and $pnum < 13
MC/DC0%0/2
$pnum > 0 and $pnum < 13
$pnum > 0
$pnum < 13
Truth table33%1/3
A and B
A= $pnum > 0B= $pnum < 13
| |||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 168 | &{$_r454_build_periods}($self); | |||||||||||||||||||||||||||
| 324 | 168 | my $pobj = $self->{_R454_periods}->{$pnum}->{ppub}->clone; | |||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 168 | ▶ | return ($asobj ? $pobj : "" . $pobj); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | sub r454_period_month | ||||||||||||||||||||||||||||
| 330 | 12 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
r454_period_month: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 331 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 332 | 12 | my %params = @_; | |||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | my $pnum = | ||||||||||||||||||||||||||||
| 335 | 12 | ▶ | defined($params{period}) ? 0 + $params{period} : $self->r454_period; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 336 | 12 | ▶ | croak "Invalid Period specified" unless $pnum > 0 && $pnum < 13; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pnum > 0 and $pnum < 13
MC/DC0%0/2
$pnum > 0 and $pnum < 13
$pnum > 0
$pnum < 13
Truth table33%1/3
A and B
A= $pnum > 0B= $pnum < 13
| |||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 12 | &{$_r454_build_periods}($self); | |||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 12 | return ($self->{_R454_periods}->{$pnum}->{month}); | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | sub truncate | ||||||||||||||||||||||||||||
| 344 | 208 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
truncate: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 345 | 208 | my $self = shift; | |||||||||||||||||||||||||||
| 346 | 208 | my %params = @_; | |||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | 208 | ▶ | if ($params{to} eq 'r454year') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 349 | 1 | my $tmp = $self->r454_start(as_obj => 1); | |||||||||||||||||||||||||||
| 350 | 1 | %{$self} = %{$tmp}; | |||||||||||||||||||||||||||
| 351 | } elsif ($params{to} eq 'period') { | ||||||||||||||||||||||||||||
| 352 | 1 | my $tmp = $self->r454_period_start(as_obj => 1); | |||||||||||||||||||||||||||
| 353 | 1 | %{$self} = %{$tmp}; | |||||||||||||||||||||||||||
| 354 | } else { | ||||||||||||||||||||||||||||
| 355 | 206 | $self->SUPER::truncate(%params); | |||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 208 | return ($self); | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 7 | 1; | |||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | __END__ | ||||||||||||||||||||||||||||