From bd60418f9d767987971ec5cd18be383294c8f64d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 21 Nov 2012 10:43:11 -0300 Subject: [PATCH] Bug 9078 - is_holiday should honour holiday exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Make is_holiday return 0 for holiday exceptions. Note: This patch makes several current ok tests fail. My first guess is test data is not constructed ok. More on this later. Sponsored-by: Universidad Nacional de Córdoba Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer Passed-QA-by: Paul Poulain Signed-off-by: Jared Camins-Esakov Signed-off-by: Chris Cormack --- Koha/Calendar.pm | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm index 3986038fda..ee63e73b1f 100644 --- a/Koha/Calendar.pm +++ b/Koha/Calendar.pm @@ -177,22 +177,31 @@ sub addDays { sub is_holiday { my ( $self, $dt ) = @_; my $localdt = $dt->clone(); + my $day = $localdt->day; + my $month = $localdt->month; + + $localdt->truncate( to => 'day' ); + + if ( $self->{exception_holidays}->contains($localdt) ) { + # exceptions are not holidays + return 0; + } + my $dow = $localdt->day_of_week; + # Representation fix + # TODO: Shouldn't we shift the rest of the $dow also? if ( $dow == 7 ) { $dow = 0; } + if ( $self->{weekly_closed_days}->[$dow] == 1 ) { return 1; } - $localdt->truncate( to => 'day' ); - my $day = $localdt->day; - my $month = $localdt->month; + if ( exists $self->{day_month_closed_days}->{$month}->{$day} ) { return 1; } - if ( $self->{exception_holidays}->contains($localdt) ) { - return 1; - } + if ( $self->{single_holidays}->contains($localdt) ) { return 1; } -- 2.39.5