From ec1d869c4de188fccb6c8d65d99bc3f6709df99b Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 10 Mar 2021 15:51:23 +0000 Subject: [PATCH] Bug 27835: Fix unit test Without this patch the unit tests fail. This highlights a potential issue When ignoring holidays we get chargeable units as: $date_returned->delta_days( $date_due ); When excluding holidays: $calendar->days_between( $date_due, $date_returned ); days_between does a loop: 328 while( $start_dt->compare($end_dt) < 1 ) { 329 $delta_days-- if $self->is_holiday($start_dt); 330 $start_dt->add( days => 1 ); 331 } Form docs https://metacpan.org/pod/DateTime#DateTime-%3Ecompare(-$dt1,-$dt2-),-DateTime-%3Ecompare_ignore_floating(-$dt1,-$dt2-) This method compare two DateTime objects. The semantics are compatible with Perl's sort function; it returns -1 if $dt1 < $dt2, 0 if $dt1 == $dt2, 1 if $dt1 > $dt2. So '2000-01-30 00:00:00' compares to itself as '0' and is less than 1 Is that correct? Or should the loop use "> -1" --- t/db_dependent/Circulation/CalcFine.t | 3 +++ 1 file changed, 3 insertions(+) diff --git a/t/db_dependent/Circulation/CalcFine.t b/t/db_dependent/Circulation/CalcFine.t index c56882bc01..be9de756e8 100755 --- a/t/db_dependent/Circulation/CalcFine.t +++ b/t/db_dependent/Circulation/CalcFine.t @@ -88,6 +88,9 @@ subtest 'Test basic functionality' => sub { year => 2000, month => 1, day => 1, + hour => 23, + minute => 59, + second => 59, ); my $end_dt = DateTime->new( -- 2.11.0