Bug 8251 - Patrons get incorrectly debarred
authorTomas Cohen Arazi <tomascohen@gmail.com>
Fri, 15 Jun 2012 17:51:42 +0000 (14:51 -0300)
committerPaul Poulain <paul.poulain@biblibre.com>
Wed, 20 Jun 2012 21:24:24 +0000 (23:24 +0200)
Patrons get incorrectly debarred because of the use of Datetime->delta_days
wich happens to always return a positive number.

Also changed the use of Datetime->truncate function so it follows the docs,
using 'day' instead of 'days' (which is used in DateTime::Duration).

This patch has been tested against master.

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Koha/Calendar.pm

index f63e7eb..dc132cd 100644 (file)
@@ -173,9 +173,9 @@ sub days_between {
     my $dateend_temp = $end_dt->clone();
 
     # start and end should not be closed days
-    my $duration = $dateend_temp->delta_days($datestart_temp);
-    $datestart_temp->truncate( to => 'days' );
-    $dateend_temp->truncate( to => 'days' );
+    $datestart_temp->truncate( to => 'day' );
+    $dateend_temp->truncate( to => 'day' );
+    my $duration = $dateend_temp - $datestart_temp;
     while ( DateTime->compare( $datestart_temp, $dateend_temp ) == -1 ) {
         $datestart_temp->add( days => 1 );
         if ( $self->is_holiday($datestart_temp) ) {