View | Details | Raw Unified | Return to bug 18607
Collapse All | Expand All

(-)a/C4/Serials.pm (-22 / +19 lines)
Lines 2294-2305 sub GetFictiveIssueNumber { Link Here
2294
            ($wkno, $year) = Week_of_Year($year, $month, $day);
2294
            ($wkno, $year) = Week_of_Year($year, $month, $day);
2295
            my ($fa_wkno, $fa_yr) = Week_of_Year($fa_year, $fa_month, $fa_day);
2295
            my ($fa_wkno, $fa_yr) = Week_of_Year($fa_year, $fa_month, $fa_day);
2296
            $delta = ($fa_yr == $year) ? ($wkno - $fa_wkno) : ( ($year-$fa_yr-1)*52 + (52-$fa_wkno+$wkno) );
2296
            $delta = ($fa_yr == $year) ? ($wkno - $fa_wkno) : ( ($year-$fa_yr-1)*52 + (52-$fa_wkno+$wkno) );
2297
        } elsif($unit eq 'month') {
2297
        } elsif( $unit eq 'month' || $unit eq 'year' ) {
2298
            $delta = ($fa_year == $year)
2298
            $delta = _delta_units( [$fa_year, $fa_month, $fa_day], [$year, $month, $day], $unit );
2299
                   ? ($month - $fa_month)
2300
                   : ( ($year-$fa_year-1)*12 + (12-$fa_month+$month) );
2301
        } elsif( $unit eq 'year' ) {
2302
            $delta = _delta_units( [ $fa_year, $fa_month, $fa_day ], [ $year, $month, $day ], 'year' );
2303
        }
2299
        }
2304
        if($frequency->{'unitsperissue'} == 1) {
2300
        if($frequency->{'unitsperissue'} == 1) {
2305
            $issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'};
2301
            $issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'};
Lines 2373-2396 sub _get_next_date_week { Link Here
2373
sub _get_next_date_month {
2369
sub _get_next_date_month {
2374
    my ($subscription, $freqdata, $year, $month, $day) = @_;
2370
    my ($subscription, $freqdata, $year, $month, $day) = @_;
2375
2371
2376
    my $fa_day;
2372
    my @newissue; # ( yy, mm, dd )
2377
    (undef, undef, $fa_day) = split /-/, $subscription->{firstacquidate};
2373
    my $delta_days = int( 30 / $freqdata->{issuesperunit} );
2378
2374
2379
    if ($subscription->{countissuesperunit} + 1 > $freqdata->{issuesperunit}){
2375
    if( $freqdata->{issuesperunit} == 1 ) {
2380
        $subscription->{countissuesperunit} = 1;
2376
        # Add full months
2381
        ($year,$month,$day) = Add_Delta_YM($year,$month,$day, 0,
2377
        @newissue = Add_Delta_YM(
2382
            $freqdata->{unitsperissue});
2378
            $year, $month, $day, 0, $freqdata->{"unitsperissue"} );
2383
        my $days_in_month = Days_in_Month($year, $month);
2379
    } elsif ( $subscription->{countissuesperunit} < $freqdata->{issuesperunit} ) {
2384
        $day = $fa_day <= $days_in_month ? $fa_day : $days_in_month;
2380
        # Add rounded number of days based on frequency.
2385
    } else {
2381
        @newissue = Add_Delta_Days( $year, $month, $day, $delta_days );
2386
        # Try to guess the next day in month
2387
        my $days_in_month = Days_in_Month($year, $month);
2388
        my $delta_days = int(($days_in_month - ($fa_day - 1)) / $freqdata->{issuesperunit});
2389
        ($year,$month,$day) = Add_Delta_Days($year, $month, $day, $delta_days);
2390
        $subscription->{countissuesperunit}++;
2382
        $subscription->{countissuesperunit}++;
2383
    } else {
2384
        # We finished a cycle of issues within a unit.
2385
        # Subtract delta * (issues - 1), add 1 month
2386
        @newissue = Add_Delta_Days( $year, $month, $day,
2387
            -$delta_days * ($freqdata->{issuesperunit} - 1) );
2388
        @newissue = Add_Delta_YM( @newissue, 0, 1 );
2389
        $subscription->{countissuesperunit} = 1;
2391
    }
2390
    }
2392
2391
    return @newissue;
2393
    return ($year, $month, $day);
2394
}
2392
}
2395
2393
2396
sub _get_next_date_year {
2394
sub _get_next_date_year {
2397
- 

Return to bug 18607