[Koha-patches] [PATCH] Bug 5601 Fix processing of DueDate return

Colin Campbell colin.campbell at ptfs-europe.com
Wed Jan 12 02:39:01 CET 2011


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
---
 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 3ff7f10..b05476c 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 c76959b..38bbba8 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 24ef78c..508a06b 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));
-- 
1.7.3.4



More information about the Koha-patches mailing list