[Koha-patches] [PATCH] Bug 9031 - Overdue items crossing DST boundary throw invalid local time exception

Robson Galluci robsongalluci at gmail.com
Wed Nov 28 23:51:15 CET 2012


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



More information about the Koha-patches mailing list