[Koha-patches] [PATCH] Bug 5632: SIP : Format dates as should be in Koha

Julian Maurice julian.maurice at biblibre.com
Mon Mar 28 14:34:31 CEST 2011


From: Henri-Damien LAURENT <henridamien.laurent at biblibre.com>

Dates comes formatted as SIP timestamp.
It surely is great for bots. But nor readable at all for human beings.
Changing messages in order to send date formatted as should be printed
---
 C4/SIP/Sip/MsgType.pm |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm
index 508a06b..97b87db 100644
--- a/C4/SIP/Sip/MsgType.pm
+++ b/C4/SIP/Sip/MsgType.pm
@@ -18,6 +18,7 @@ use Sip::Checksum qw(verify_cksum);
 use Data::Dumper;
 use CGI;
 use C4::Auth qw(&check_api_auth);
+use C4::Dates;
 
 use UNIVERSAL qw(can);	# make sure this is *after* C4 modules.
 
@@ -545,7 +546,7 @@ sub handle_checkout {
 	$resp .= add_field(FID_ITEM_ID, $item_id);
 	$resp .= add_field(FID_TITLE_ID, $item->title_id);
     if ($item->due_date) {
-        $resp .= add_field(FID_DUE_DATE, Sip::timestamp($item->due_date));
+        $resp .= add_field(FID_DUE_DATE, C4::Dates->new($item->due_date, 'iso')->output() );
     } else {
         $resp .= add_field(FID_DUE_DATE, q{});
     }
@@ -988,7 +989,7 @@ sub handle_patron_info {
 
         # SIP 2.0 extensions used by Envisionware
         # Other terminals will ignore unrecognized fields (unrecognized field identifiers)
-        $resp .= maybe_add(FID_PATRON_BIRTHDATE, $patron->birthdate);
+        $resp .= maybe_add(FID_PATRON_BIRTHDATE, C4::Dates->new($patron->birthdate, 'iso')->output() );
         $resp .= maybe_add(FID_PATRON_CLASS,     $patron->ptype);
 
         # Custom protocol extension to report patron internet privileges
@@ -1128,13 +1129,13 @@ sub handle_item_information {
 	    $resp .= add_field(FID_HOLD_QUEUE_LEN, $i);
 	}
 	if ($item->due_date) {
-	    $resp .= add_field(FID_DUE_DATE, Sip::timestamp($item->due_date));
+	    $resp .= add_field(FID_DUE_DATE, C4::Dates->new($item->due_date, 'iso')->output() );
 	}
 	if (($i = $item->recall_date) != 0) {
-	    $resp .= add_field(FID_RECALL_DATE, Sip::timestamp($i));
+	    $resp .= add_field(FID_RECALL_DATE, C4::Dates->new($i, 'iso')->output() );
 	}
 	if (($i = $item->hold_pickup_date) != 0) {
-	    $resp .= add_field(FID_HOLD_PICKUP_DATE, Sip::timestamp($i));
+	    $resp .= add_field(FID_HOLD_PICKUP_DATE, C4::Dates->new($i, 'iso')->output() );
 	}
 
 	$resp .= maybe_add(FID_SCREEN_MSG, $item->screen_msg);
@@ -1360,7 +1361,7 @@ sub handle_renew {
 	$resp .= add_field(FID_PATRON_ID, $patron->id);
 	$resp .= add_field(FID_ITEM_ID,  $item->id);
 	$resp .= add_field(FID_TITLE_ID, $item->title_id);
-	$resp .= add_field(FID_DUE_DATE, Sip::timestamp($item->due_date));
+	$resp .= add_field(FID_DUE_DATE, C4::Dates->new($item->due_date, 'iso')->output() );
 	if ($ils->supports('security inhibit')) {
 	    $resp .= add_field(FID_SECURITY_INHIBIT,
 			       $status->security_inhibit);
-- 
1.7.4.1



More information about the Koha-patches mailing list