From 063a1fe66dd3b3bba71fbc2f696bde10cebbb43d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 2 Jul 2012 11:30:08 -0400 Subject: [PATCH] Bug 8110 - Followup - Make days_between return a number of days, instead of an object. --- C4/Circulation.pm | 4 ++-- C4/Overdues.pm | 2 +- Koha/Calendar.pm | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index ca2e94d..598743a 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1846,8 +1846,8 @@ sub _FixFineDaysOnReturn { # grace period is measured in the same units as the loan my $grace = DateTime::Duration->new( $unit => $issuingrule->{firstremind} ); - if ( ( $deltadays - $grace )->is_positive ) { # you can't compare DateTime::Durations with logical operators - my $new_debar_dt = $dt_today->clone()->add_duration( $deltadays * $finedays ); + if ( $deltadays - $grace->in_units('days') { + my $new_debar_dt = $dt_today->clone()->add_duration( DateTime::Duration->new( days => $deltadays * $finedays ) ); my $borrower_debar_dt = dt_from_string( $borrower->{debarred} ); # check to see if the current debar date is a valid date if ( $borrower->{debarred} && $borrower_debar_dt ) { diff --git a/C4/Overdues.pm b/C4/Overdues.pm index ffdeaf5..471c63a 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -309,7 +309,7 @@ sub _get_chargeable_units { else { # days if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') { my $calendar = Koha::Calendar->new( branchcode => $branchcode ); - $charge_duration = $calendar->days_between( $dt1, $dt2 ); + return $calendar->days_between( $dt1, $dt2 ); } else { $charge_duration = $dt2->delta_days( $dt1 ); } diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm index dc132cd..b7d75e4 100644 --- a/Koha/Calendar.pm +++ b/Koha/Calendar.pm @@ -182,7 +182,7 @@ sub days_between { $duration->subtract( days => 1 ); } } - return $duration; + return $duration->in_units('days'); } -- 1.7.2.5