Bugzilla – Attachment 64027 Details for
Bug 18697
Fix date calculations for day/week frequencies in Serials
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 18697: Fix date calculation for dayly frequencies in Serials
SIGNED-OFF-Bug-18697-Fix-date-calculation-for-dayl.patch (text/plain), 3.89 KB, created by
Josef Moravec
on 2017-06-06 07:52:33 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 18697: Fix date calculation for dayly frequencies in Serials
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2017-06-06 07:52:33 UTC
Size:
3.89 KB
patch
obsolete
>From d83aa1d4e1b4ed23c1dc408e557d632b08bacfef Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 30 May 2017 16:44:46 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 18697: Fix date calculation for dayly > frequencies in Serials > >The changes in _get_next_date_day are actually only cosmetic. The sub >now reads exactly the same as its counterparts for other units, but >the results are exactly the same as before. > >In GetFictiveIssueNumber we now call _delta_units for each type of unit. >The two Delta_Days calls are moved to _delta_units. Note that this also >is a cosmetic change; results should be exactly the same. > >Test plan: >[1] Edit a subscription. Test predication pattern for some daily freq. >[2] Run t/db_dependent/GetNextDate.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > C4/Serials.pm | 46 ++++++++++++++++++++++++++++------------------ > 1 file changed, 28 insertions(+), 18 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 2f3cb2d..3a9b1d6 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -2286,15 +2286,8 @@ sub GetFictiveIssueNumber { > my ($year, $month, $day) = split /-/, $publisheddate; > my ($fa_year, $fa_month, $fa_day) = split /-/, $subscription->{'firstacquidate'}; > my $wkno; >- my $delta; >- >- if($unit eq 'day') { >- $delta = Delta_Days($fa_year, $fa_month, $fa_day, $year, $month, $day); >- } elsif($unit eq 'week') { >- $delta = int( Delta_Days($fa_year, $fa_month, $fa_day, $year, $month, $day) / 7); >- } elsif( $unit eq 'month' || $unit eq 'year' ) { >- $delta = _delta_units( [$fa_year, $fa_month, $fa_day], [$year, $month, $day], $unit ); >- } >+ my $delta = _delta_units( [$fa_year, $fa_month, $fa_day], [$year, $month, $day], $unit ); >+ > if($frequency->{'unitsperissue'} == 1) { > $issueno = $delta * $frequency->{'issuesperunit'} + $subscription->{'countissuesperunit'}; > } else { >@@ -2306,10 +2299,17 @@ sub GetFictiveIssueNumber { > } > > sub _delta_units { >-# wrapper around N_Delta_YMD >-# Note that N_Delta_YMD returns 29 days between e.g. 22-2-72 and 22-3-72 >-# while we expect 1 month. > my ( $date1, $date2, $unit ) = @_; >+ >+ if( $unit eq 'day' ) { >+ return Delta_Days( @$date1, @$date2 ); >+ } elsif( $unit eq 'week' ) { >+ return int( Delta_Days( @$date1, @$date2 ) / 7 ); >+ } >+ >+ # In case of months or years, this is a wrapper around N_Delta_YMD. >+ # Note that N_Delta_YMD returns 29 days between e.g. 22-2-72 and 22-3-72 >+ # while we expect 1 month. > my @delta = N_Delta_YMD( @$date1, @$date2 ); > if( $delta[2] > 27 ) { > # Check if we could add a month >@@ -2329,14 +2329,24 @@ sub _delta_units { > sub _get_next_date_day { > my ($subscription, $freqdata, $year, $month, $day) = @_; > >- if ($subscription->{countissuesperunit} + 1 > $freqdata->{issuesperunit}){ >- ($year,$month,$day) = Add_Delta_Days($year,$month, $day , $freqdata->{unitsperissue} ); >- $subscription->{countissuesperunit} = 1; >- } else { >+ my @newissue; # ( yy, mm, dd ) >+ # We do not need $delta_days here, since it would be zero where used >+ >+ if( $freqdata->{issuesperunit} == 1 ) { >+ # Add full days >+ @newissue = Add_Delta_Days( >+ $year, $month, $day, $freqdata->{"unitsperissue"} ); >+ } elsif ( $subscription->{countissuesperunit} < $freqdata->{issuesperunit} ) { >+ # Add zero days >+ @newissue = ( $year, $month, $day ); > $subscription->{countissuesperunit}++; >+ } else { >+ # We finished a cycle of issues within a unit. >+ # No subtraction of zero needed, just add one day >+ @newissue = Add_Delta_Days( $year, $month, $day, 1 ); >+ $subscription->{countissuesperunit} = 1; > } >- >- return ($year, $month, $day); >+ return @newissue; > } > > sub _get_next_date_week { >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18697
:
63846
|
63847
|
63867
|
63868
|
63869
|
63870
|
63871
|
64025
|
64026
|
64027
|
64028
|
64029
|
64317
|
64318
|
64319
|
64320
|
64321