@@ -, +, @@ --- Koha/Calendar.pm | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) --- a/Koha/Calendar.pm +++ a/Koha/Calendar.pm @@ -176,10 +176,15 @@ sub days_between { $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) ) { - $duration->subtract( days => 1 ); + # if borrower is not late, delta days must be negative + if(DateTime->compare( $start_dt, $end_dt ) > -1){ + $duration = $duration->inverse; + } else { + while ( DateTime->compare( $datestart_temp, $dateend_temp ) == -1 ) { + $datestart_temp->add( days => 1 ); + if ( $self->is_holiday($datestart_temp) ) { + $duration->subtract( days => 1 ); + } } } return $duration; --