View | Details | Raw Unified | Return to bug 8251
Collapse All | Expand All

(-)a/Koha/Calendar.pm (-8 / +12 lines)
Lines 173-186 sub days_between { Link Here
173
    my $dateend_temp = $end_dt->clone();
173
    my $dateend_temp = $end_dt->clone();
174
174
175
    # start and end should not be closed days
175
    # start and end should not be closed days
176
    $datestart_temp->truncate( to => 'day' );
177
    $dateend_temp->truncate( to => 'day' );
176
    my $duration = $dateend_temp->delta_days($datestart_temp);
178
    my $duration = $dateend_temp->delta_days($datestart_temp);
177
    $datestart_temp->truncate( to => 'days' );
179
    # if borrower is not late, delta days must be negative
178
    $dateend_temp->truncate( to => 'days' );
180
    if(DateTime->compare( $start_dt, $end_dt ) > -1){
179
    while ( DateTime->compare( $datestart_temp, $dateend_temp ) == -1 ) {
181
	$duration = $duration->inverse;
180
        $datestart_temp->add( days => 1 );
182
    } else {
181
        if ( $self->is_holiday($datestart_temp) ) {
183
	while ( DateTime->compare( $datestart_temp, $dateend_temp ) == -1 ) {
182
            $duration->subtract( days => 1 );
184
	    $datestart_temp->add( days => 1 );
183
        }
185
	    if ( $self->is_holiday($datestart_temp) ) {
186
		$duration->subtract( days => 1 );
187
	    }
188
	}
184
    }
189
    }
185
    return $duration;
190
    return $duration;
186
191
187
- 

Return to bug 8251