koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/C4/Calendar Calendar.pm [dev_week]


From: Ryan Higgins
Subject: [Koha-cvs] koha/C4/Calendar Calendar.pm [dev_week]
Date: Mon, 09 Apr 2007 17:35:19 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Ryan Higgins <rych>     07/04/09 17:35:19

Modified files:
        C4/Calendar    : Calendar.pm 

Log message:
        add option for calculating holidays-corrected dates

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Calendar/Calendar.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.5&r2=1.1.2.6

Patches:
Index: Calendar.pm
===================================================================
RCS file: /sources/koha/koha/C4/Calendar/Attic/Calendar.pm,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -b -r1.1.2.5 -r1.1.2.6
--- Calendar.pm 25 Jan 2007 05:40:19 -0000      1.1.2.5
+++ Calendar.pm 9 Apr 2007 17:35:19 -0000       1.1.2.6
@@ -19,11 +19,11 @@
 require Exporter;
 use vars qw($VERSION @EXPORT);
 
-use Date::Manip;
-# use Date::Calc; 
+#use Date::Manip;
+ use Date::Calc; 
  
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.1.2.5 $' =~ /\d+/g; shift(@v).".".join( 
"_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.1.2.6 $' =~ /\d+/g; shift(@v).".".join( 
"_", map { sprintf "%03d", $_ } @v ); };
 
 =head1 NAME
 
@@ -473,6 +473,12 @@
 
 C<$offset> Is the number of days that this function has to count from $date.
 
+System Preference 'useDaysMode' controls behavior:
+Days -> ignore holidays.
+Datedue -> if normally calculated date due falls on a holiday, extend the loan 
length
+to the next non-holiday.
+Calendar (default) -> only non-holiday dates count toward the loan length.
+
 =cut
 
 sub addDate {
@@ -483,16 +489,19 @@
     }
 
     my $daysMode = C4::Context->preference('useDaysMode');
-    if ($daysMode eq 'normal') {
-        ($year, $month, $day) = &Date::Calc::Add_Delta_Days($year, $month, 
$day, ($offset - 1));
-    } else {
+    if ($daysMode eq 'Days') {
+        ($year, $month, $day) = Add_Delta_Days($year, $month, $day, $offset );
+    } elsif ($daysMode eq 'Duedate') {
+        ($year, $month, $day) = Add_Delta_Days($year, $month, $day, $offset );
+        while ($self->isHoliday($day, $month, $year)) {
+                ($year, $month, $day) = Add_Delta_Days($year, $month, $day, 1);
+        }
+    } else {            ### ($daysMode eq 'Calendar') {
         while ($offset > 0) {
+                ($year, $month, $day) = Add_Delta_Days($year, $month, $day, 1);
             if (!($self->isHoliday($day, $month, $year))) {
                 $offset = $offset - 1;
             }
-            if ($offset > 0) {
-                ($year, $month, $day) = &Date::Calc::Add_Delta_Days($year, 
$month, $day, 1);
-            }
         }
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]