[Koha-cvs] koha/C4 Serials.pm [rel_3_0]

Henri-Damien LAURENT laurenthdl at alinto.com
Tue Jan 16 11:46:09 CET 2007


CVSROOT:	/cvsroot/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Henri-Damien LAURENT <hdl>	07/01/16 10:46:09

Modified files:
	C4             : Serials.pm 

Log message:
	BUG FIXING : Problems with week number calculations.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Serials.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.5.2.25&r2=1.5.2.26

Patches:
Index: Serials.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Serials.pm,v
retrieving revision 1.5.2.25
retrieving revision 1.5.2.26
diff -u -b -r1.5.2.25 -r1.5.2.26
--- Serials.pm	16 Jan 2007 10:02:05 -0000	1.5.2.25
+++ Serials.pm	16 Jan 2007 10:46:09 -0000	1.5.2.26
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Serials.pm,v 1.5.2.25 2007/01/16 10:02:05 hdl Exp $
+# $Id: Serials.pm,v 1.5.2.26 2007/01/16 10:46:09 hdl Exp $
 
 use strict;
 use C4::Date;
@@ -35,7 +35,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.5.2.25 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.5.2.26 $' =~ /\d+/g;
     shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
 };
 
@@ -1672,12 +1672,16 @@
             $startdate[0],$startdate[1],$startdate[2],
             ,0,$subscription->{monthlength},0) if ( $subscription->{monthlength} );
         if ( $subscription->{weeklength} ){
-          my ($year,$weeknb)=Week_of_Year(@startdate);
+          my ($weeknb,$year)=Week_of_Year(@startdate);
           $weeknb += $subscription->{weeklength};
-          @endofsubscriptiondate=Monday_of_Week($year,$weeknb);
-        }
-#         foreach (@endofsubscriptiondate){warn "endofsubscription :$_"}
-        my $endofsubscriptiondate=Date_to_Time($endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2],0,0,0) if (@endofsubscriptiondate);
+          my $weeknbcalc= $weeknb % 52;
+          $year += int($weeknb/52);
+          warn "year : $year weeknb :$weeknb weeknbcalc $weeknbcalc";
+          @endofsubscriptiondate=Monday_of_Week($weeknbcalc,$year);
+        }
+        foreach (@endofsubscriptiondate){warn "endofsubscription :$_"}
+        my $endofsubscriptiondate = Date_to_Time($endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2],
+        0,0,0) if (@endofsubscriptiondate);
         return 1 if ( (@endofsubscriptiondate && Delta_Days($res[0],$res[1],$res[2],
                       $endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2]) >= 0)
                       || (!$res));
@@ -2224,9 +2228,11 @@
             $startdate[0],$startdate[1],$startdate[2],
             ,0,$subscription->{monthlength},0) if ( $subscription->{monthlength} );
         if ( $subscription->{weeklength} ){
-          my ($year,$weeknb)=Week_of_Year(@startdate);
+          my ($weeknb,$year)=Week_of_Year(@startdate);
           $weeknb += $subscription->{weeklength};
-          @endofsubscriptiondate=Monday_of_Week($year,$weeknb);
+          my $weeknbcalc= $weeknb % 52;
+          $year += int($weeknb/52);
+          @endofsubscriptiondate=Monday_of_Week($weeknbcalc,$year);
         }
         # defaulting hours to 0
         my $endofsubscriptiondate=Date_to_Time($endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2]
@@ -2502,6 +2508,15 @@
 FIXME : have to replace Date::Manip by Date::Calc in this function to improve performances.
 
 =cut
+sub in_array { # used in next sub down
+            my ($val, at elements) = @_;
+            foreach my $elem(@elements) {
+		            if($val == $elem) {
+				                    return 1;
+				            }
+		        }
+        return 0;
+    }
 
 sub GetNextDate(@) {
     my ( $planneddate, $subscription ) = @_;





More information about the Koha-cvs mailing list