[Koha-bugs] [Bug 27835] Closed days offsets with one day
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Wed Mar 10 16:58:41 CET 2021
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27835
--- Comment #13 from Nick Clemens <nick at bywatersolutions.com> ---
Created attachment 118033
-->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=118033&action=edit
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"
--
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.
More information about the Koha-bugs
mailing list