From 588a40a14fb7e33229e07f8260b73532aa7ddd67 Mon Sep 17 00:00:00 2001
From: Robson Galluci <robsongalluci@gmail.com>
Date: Tue, 27 Nov 2012 20:04:06 -0200
Subject: [PATCH] Bug 9031 - Overdue items crossing DST boundary throw invalid local time exception

This patch converts $start_dt and $end_dt to UTC before performing the calculation of the number of days between due date and actual check in date.
---
 Koha/Calendar.pm |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm
index 90069b6..7075c49 100644
--- a/Koha/Calendar.pm
+++ b/Koha/Calendar.pm
@@ -241,6 +241,8 @@ sub days_between {
     my $start_dt = shift;
     my $end_dt   = shift;
 
+    $start_dt->set_time_zone('UTC');
+    $end_dt->set_time_zone('UTC');
 
     # start and end should not be closed days
     my $days = $start_dt->delta_days($end_dt)->delta_days;
@@ -263,6 +265,10 @@ sub hours_between {
     my $duration = $end_dt->delta_ms($start_dt);
     $start_dt->truncate( to => 'day' );
     $end_dt->truncate( to => 'day' );
+
+    $start_dt->set_time_zone('UTC');
+    $end_dt->set_time_zone('UTC');
+
     # NB this is a kludge in that it assumes all days are 24 hours
     # However for hourly loans the logic should be expanded to
     # take into account open/close times then it would be a duration
-- 
1.7.2.5