Bug 8966

Summary: Koha::Calendar::is_holiday truncates the date
Product: Koha Reporter: Maxime Pelletier <pelletiermaxime>
Component: CirculationAssignee: Maxime Pelletier <pelletiermaxime>
Status: CLOSED FIXED QA Contact: Paul Poulain <paul.poulain>
Severity: critical    
Priority: P5 - low CC: chris, dcook, gmcharlt, kyle.m.hall, paul.poulain, tomascohen
Version: 3.8   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8882
Change sponsored?: Sponsored Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: patch to fix the bug and a test
Patch with a comment in the test to see this bug
Bug 8966 Koha::Calendar::is_holiday truncates the date

Description Maxime Pelletier 2012-10-24 21:26:31 UTC
Calling the function is_holiday on a date truncate that dates because it does a truncate directly on it instead of using a local clone of the date.
Comment 1 Maxime Pelletier 2012-10-24 21:31:11 UTC Comment hidden (obsolete)
Comment 2 Maxime Pelletier 2012-10-24 21:35:28 UTC Comment hidden (obsolete)
Comment 3 Maxime Pelletier 2012-10-25 14:29:40 UTC
Forgot to mention that this is sponsored by CCSR.
Comment 4 Tomás Cohen Arazi 2012-10-26 00:32:04 UTC
Created attachment 13068 [details] [review]
Bug 8966 Koha::Calendar::is_holiday truncates the date

* Create a local copy of the date instead of calling truncate directly on the date
* Add a test to properly test that the issue is fixed

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Comment 5 Paul Poulain 2012-10-29 17:28:04 UTC
QA comment:
 * thanks for the updated Calendar.t, it helped me understand what the patch was fixing
 * small patch, add a test ++
 * passes koha-qa.pl
 * prove t/Calendar.t => All tests successful.

passed QA
Comment 6 Paul Poulain 2012-10-29 17:28:22 UTC
Patch pushed to master
Comment 7 Chris Cormack 2012-10-30 21:50:04 UTC
Pushed to 3.8.x, will be in 3.8.7
Comment 8 David Cook 2016-05-04 02:40:25 UTC
I just noticed that the Calendar.t uses a DateTime object with a timezone of Europe/London. 

If we change the test to include the following,

my $dt = DateTime->new(
    month => 9,
    year => 2015,
    day => 6,
    hour => 12,
    minute => 00,
    second => 00,
    time_zone => 'America/Santiago',
my $calendar = Koha::Calendar->new(branchcode => "MAIN");

We'll get a fatal error with the following message:

Invalid local time for date in time zone: America/Santiago

See https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16376