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

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Nov 28 01:01:37 CET 2012


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9031

--- Comment #6 from Robson Galluci <robsongalluci at hotmail.com> ---
Anyway, I've sent it to the patches list, but it's now awaiting moderation
because I used my GMail account, while my subscription uses Hotmail.

Forgive the noobness, it's my first time doing this stuff.

I still have the file though, I can post it again. It looks like this:


>From 588a40a14fb7e33229e07f8260b73532aa7ddd67 Mon Sep 17 00:00:00 2001
From: Robson Galluci <robsongalluci at 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

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list