[Koha-bugs] [Bug 12847] New: Date comparisons in C4::Members::IssueSlip is broken

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Aug 28 21:00:15 CEST 2014


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12847

            Bug ID: 12847
           Summary: Date comparisons in C4::Members::IssueSlip is broken
 Change sponsored?: ---
           Product: Koha
           Version: 3.14
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5 - low
         Component: Notices
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: barton at bywatersolutions.com
        QA Contact: testopia at bugs.koha-community.org

In C4/Members.pm:

2379 sub IssueSlip {
2380     my ($branch, $borrowernumber, $quickslip) = @_;
2381 
2382 #   return unless (
C4::Context->boolean_preference('printcirculationslips') );
2383 
2384     my $now       = POSIX::strftime("%Y-%m-%d", localtime);
2385 
2386     my $issueslist = GetPendingIssues($borrowernumber);
2387     foreach my $it (@$issueslist){
2388         if ((substr $it->{'issuedate'}, 0, 10) eq $now || (substr
$it->{'lastreneweddate'}, 0, 10) eq $now) {
2389             $it->{'now'} = 1;
2390         }
2391         elsif ((substr $it->{'date_due'}, 0, 10) le $now) {
2392             $it->{'overdue'} = 1;
2393         }
2394         my $dt = dt_from_string( $it->{'date_due'} );
2395         $it->{'date_due'} = output_pref( $dt );;
2396     }

At line 2384, $now is being defined with the format "%Y-%m-%d", however this is
being compared against 'issuedate', 'lastrenewdate' and 'date_due'.

'date_due' is formatted '09/04/2014 23:59'

The comparison only uses the first 10 characters of 'date_due', so we can
ignore the timestamp at the end, but it's trying to compare 'YYYY-MM-DD'
against 'MM/YY/DDDD', e.g. 2014-08-28 against 09/04/2014 -- This is a string
comparison; so the initial '0' in '09/04/2014' sorts before the '2' in
'2014-08-28'... since the date due is less than $now, the 'overdue' flag is set
for this item.

I believe that all of the dates involved (issuedate, lastreneweddate, and
date_due) are Koha::DateUtils objects; as such it should be possible to define
$now the same way, and use Koha::DateUtils methods directly for date
comparisons, rather than doing string comparisons.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list