Bugzilla – Attachment 58002 Details for
Bug 16376
Koha::Calendar->is_holiday date truncation creates fatal errors for TZ America/Santiago
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16376 - Koha::Calendar->is_holiday date truncation creates fatal errors for TZ America/Santiago
Bug-16376---KohaCalendar-isholiday-date-truncation.patch (text/plain), 2.55 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-12-06 14:40:23 UTC
(
hide
)
Description:
Bug 16376 - Koha::Calendar->is_holiday date truncation creates fatal errors for TZ America/Santiago
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-12-06 14:40:23 UTC
Size:
2.55 KB
patch
obsolete
>From afcee84c0b1e4e9e1640ffc7e48be7b937899a45 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >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. > >Edit: > >While the changes to is_holiday and single_holiday make sense (Jonathan agrees too) >I didn't manage to have them fail, because truncate is not failing in my trials, but >days_between. So to me, it narrows down to have exception_holiday return floating tz >datetime objects so it doesn't break days_between. > >Anyway, it is ok to push this patch, and the regression test I provide covers this scenario >I'm describing. > >To test: >- Apply the regression tests patch >- Run: > $ prove t/db_dependent/Holidays.t >=> FAIL: Unexpected error due to bad timezone/date combination >- Apply this patch >- Run: > $ prove t/db_dependent/Holidays.t >=> SUCCESS: Tests pass > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Calendar.pm | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > >diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm >index eed55cb..f6cb58c 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.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16376
:
51702
|
51906
|
51968
|
58001
| 58002