From d4842d45601bd0f9c1bd33bf7978586ae746888f Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Wed, 12 Jan 2011 07:34:21 +0100 Subject: [PATCH] Bug 5601 Fix processing of DueDate return MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit item duedate is not a datetime entity but a string retrieved direct from the db that only needs restructuring checkout was doing so but item_info was pretending it was in secs (actually Item.pm manipulated then overwrote it!!) assume the date in the db is correct (otherwise madness ensues) dont try to second guess it As duedates do not yet include a time element assume end of day as a safety first [F. Demians] I confirm Joe Atzberger diagnostic. That's a bug reported by a library. I've tested Colin Campell solution. It fixes the bug. Signed-off-by: Frédéric Demians Signed-off-by: Chris Cormack --- C4/SIP/ILS/Item.pm | 11 ++--------- C4/SIP/Sip.pm | 8 ++------ C4/SIP/Sip/MsgType.pm | 4 ++-- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/C4/SIP/ILS/Item.pm b/C4/SIP/ILS/Item.pm index 3ff7f105ae..b05476c684 100644 --- a/C4/SIP/ILS/Item.pm +++ b/C4/SIP/ILS/Item.pm @@ -9,7 +9,6 @@ package ILS::Item; use strict; use warnings; -use DateTime; use Sys::Syslog qw(syslog); use Carp; @@ -98,13 +97,8 @@ sub new { # check if its on issue and if so get the borrower my $issue = GetItemIssue($item->{'itemnumber'}); - if ( $issue ) { - my $date = $issue->{ date_due }; - my $dt = DateTime->new( - year => substr($date, 0, 4), - month => substr($date,5,2), - day => substr($date, 8, 2) ); - $item->{ due_date } = $dt->epoch(); + if ($issue) { + $item->{due_date} = $issue->{date_due}; } my $borrower = GetMember(borrowernumber=>$issue->{'borrowernumber'}); $item->{patron} = $borrower->{'cardnumber'}; @@ -112,7 +106,6 @@ sub new { $item->{hold_queue} = [ sort priority_sort @$arrayref ]; $item->{hold_shelf} = [( grep { defined $_->{found} and $_->{found} eq 'W' } @{$item->{hold_queue}} )]; $item->{pending_queue} = [( grep {(! defined $_->{found}) or $_->{found} ne 'W' } @{$item->{hold_queue}} )]; - $item->{due_date} = $issue->{date_due}; $self = $item; bless $self, $type; diff --git a/C4/SIP/Sip.pm b/C4/SIP/Sip.pm index c76959b657..38bbba85ce 100644 --- a/C4/SIP/Sip.pm +++ b/C4/SIP/Sip.pm @@ -9,7 +9,6 @@ use warnings; use English; use Exporter; -use DateTime; use Sys::Syslog qw(syslog); use POSIX qw(strftime); use Socket qw(:crlf); @@ -51,11 +50,8 @@ our $last_response = ''; sub timestamp { my $time = $_[0] || time(); if ($time=~m/^(\d{4})\-(\d{2})\-(\d{2})/) { - my $dt = DateTime->new( - year => $1, - month => $2, - day => $3); - $time = $dt->epoch(); + # passing a db returned date as is + bogus time + return sprintf( '%04d%02d%02d 235900', $1, $2, $3); } return strftime(SIP_DATETIME, localtime($time)); } diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 24ef78ce85..508a06ba5a 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -1127,8 +1127,8 @@ sub handle_item_information { if (($i = scalar @{$item->hold_queue}) > 0) { $resp .= add_field(FID_HOLD_QUEUE_LEN, $i); } - if (($i = $item->due_date) != 0) { - $resp .= add_field(FID_DUE_DATE, Sip::timestamp($i)); + if ($item->due_date) { + $resp .= add_field(FID_DUE_DATE, Sip::timestamp($item->due_date)); } if (($i = $item->recall_date) != 0) { $resp .= add_field(FID_RECALL_DATE, Sip::timestamp($i)); -- 2.39.5