From 341d965a3934d2fded1289cb38aee35bd4389935 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 23 May 2016 11:57:04 +1000 Subject: [PATCH] Bug 16376 - Koha::Calendar->is_holiday date truncation creates fatal errors for TZ America/Santiago Using a DateTime object with a timezone of America/Santiago was causing fatal errors for Koha::Calendar->is_holiday and Koha::Calendar->exception_holidays, when the objects were truncated to an invalid local time. Using a floating zone allows us to use the same day, month, year for comparison purposes without running into the possibility of creating an invalid local time and thus a fatal software error. Signed-off-by: Chris Cormack --- Koha/Calendar.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm index 1321621..3a179fd 100644 --- a/Koha/Calendar.pm +++ b/Koha/Calendar.pm @@ -72,7 +72,7 @@ sub exception_holidays { day => $day, month => $month, year => $year, - time_zone => C4::Context->tz() + time_zone => "floating", )->truncate( to => 'day' ); } $self->{exception_holidays} = @@ -118,7 +118,7 @@ sub single_holidays { day => $day, month => $month, year => $year, - time_zone => C4::Context->tz() + time_zone => 'floating', )->truncate( to => 'day' ); push @ymd_arr, $dt->ymd(''); } @@ -235,6 +235,8 @@ sub is_holiday { my $day = $localdt->day; my $month = $localdt->month; + #Change timezone to "floating" before doing any calculations or comparisons + $localdt->set_time_zone("floating"); $localdt->truncate( to => 'day' ); -- 2.1.4