Lines 2286-2300
sub GetFictiveIssueNumber {
Link Here
|
2286 |
my ($year, $month, $day) = split /-/, $publisheddate; |
2286 |
my ($year, $month, $day) = split /-/, $publisheddate; |
2287 |
my ($fa_year, $fa_month, $fa_day) = split /-/, $subscription->{'firstacquidate'}; |
2287 |
my ($fa_year, $fa_month, $fa_day) = split /-/, $subscription->{'firstacquidate'}; |
2288 |
my $wkno; |
2288 |
my $wkno; |
2289 |
my $delta; |
2289 |
my $delta = _delta_units( [$fa_year, $fa_month, $fa_day], [$year, $month, $day], $unit ); |
2290 |
|
2290 |
|
2291 |
if($unit eq 'day') { |
|
|
2292 |
$delta = Delta_Days($fa_year, $fa_month, $fa_day, $year, $month, $day); |
2293 |
} elsif($unit eq 'week') { |
2294 |
$delta = int( Delta_Days($fa_year, $fa_month, $fa_day, $year, $month, $day) / 7); |
2295 |
} elsif( $unit eq 'month' || $unit eq 'year' ) { |
2296 |
$delta = _delta_units( [$fa_year, $fa_month, $fa_day], [$year, $month, $day], $unit ); |
2297 |
} |
2298 |
if($frequency->{'unitsperissue'} == 1) { |
2291 |
if($frequency->{'unitsperissue'} == 1) { |
2299 |
$issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'}; |
2292 |
$issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'}; |
2300 |
} else { |
2293 |
} else { |
Lines 2306-2315
sub GetFictiveIssueNumber {
Link Here
|
2306 |
} |
2299 |
} |
2307 |
|
2300 |
|
2308 |
sub _delta_units { |
2301 |
sub _delta_units { |
2309 |
# wrapper around N_Delta_YMD |
|
|
2310 |
# Note that N_Delta_YMD returns 29 days between e.g. 22-2-72 and 22-3-72 |
2311 |
# while we expect 1 month. |
2312 |
my ( $date1, $date2, $unit ) = @_; |
2302 |
my ( $date1, $date2, $unit ) = @_; |
|
|
2303 |
|
2304 |
if( $unit eq 'day' ) { |
2305 |
return Delta_Days( @$date1, @$date2 ); |
2306 |
} elsif( $unit eq 'week' ) { |
2307 |
return int( Delta_Days( @$date1, @$date2 ) / 7 ); |
2308 |
} |
2309 |
|
2310 |
# In case of months or years, this is a wrapper around N_Delta_YMD. |
2311 |
# Note that N_Delta_YMD returns 29 days between e.g. 22-2-72 and 22-3-72 |
2312 |
# while we expect 1 month. |
2313 |
my @delta = N_Delta_YMD( @$date1, @$date2 ); |
2313 |
my @delta = N_Delta_YMD( @$date1, @$date2 ); |
2314 |
if( $delta[2] > 27 ) { |
2314 |
if( $delta[2] > 27 ) { |
2315 |
# Check if we could add a month |
2315 |
# Check if we could add a month |
Lines 2329-2342
sub _delta_units {
Link Here
|
2329 |
sub _get_next_date_day { |
2329 |
sub _get_next_date_day { |
2330 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
2330 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
2331 |
|
2331 |
|
2332 |
if ($subscription->{countissuesperunit} + 1 > $freqdata->{issuesperunit}){ |
2332 |
my @newissue; # ( yy, mm, dd ) |
2333 |
($year,$month,$day) = Add_Delta_Days($year,$month, $day , $freqdata->{unitsperissue} ); |
2333 |
# We do not need $delta_days here, since it would be zero where used |
2334 |
$subscription->{countissuesperunit} = 1; |
2334 |
|
2335 |
} else { |
2335 |
if( $freqdata->{issuesperunit} == 1 ) { |
|
|
2336 |
# Add full days |
2337 |
@newissue = Add_Delta_Days( |
2338 |
$year, $month, $day, $freqdata->{"unitsperissue"} ); |
2339 |
} elsif ( $subscription->{countissuesperunit} < $freqdata->{issuesperunit} ) { |
2340 |
# Add zero days |
2341 |
@newissue = ( $year, $month, $day ); |
2336 |
$subscription->{countissuesperunit}++; |
2342 |
$subscription->{countissuesperunit}++; |
|
|
2343 |
} else { |
2344 |
# We finished a cycle of issues within a unit. |
2345 |
# No subtraction of zero needed, just add one day |
2346 |
@newissue = Add_Delta_Days( $year, $month, $day, 1 ); |
2347 |
$subscription->{countissuesperunit} = 1; |
2337 |
} |
2348 |
} |
2338 |
|
2349 |
return @newissue; |
2339 |
return ($year, $month, $day); |
|
|
2340 |
} |
2350 |
} |
2341 |
|
2351 |
|
2342 |
sub _get_next_date_week { |
2352 |
sub _get_next_date_week { |
2343 |
- |
|
|