* 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>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
sub is_holiday {
my ( $self, $dt ) = @_;
- my $dow = $dt->day_of_week;
+ my $localdt = $dt->clone();
+ my $dow = $localdt->day_of_week;
if ( $dow == 7 ) {
$dow = 0;
}
if ( $self->{weekly_closed_days}->[$dow] == 1 ) {
return 1;
}
- $dt->truncate( to => 'day' );
- my $day = $dt->day;
- my $month = $dt->month;
+ $localdt->truncate( to => 'day' );
+ my $day = $localdt->day;
+ my $month = $localdt->month;
if ( exists $self->{day_month_closed_days}->{$month}->{$day} ) {
return 1;
}
use strict;
use warnings;
use DateTime;
-use Test::More tests => 21;
+use Test::More tests => 23;
use Koha::DateUtils;
BEGIN {
cmp_ok( $ret->ymd(), 'eq', '2012-07-30', 'Add 7 days Days mode' );
$cal->set_daysmode('Calendar');
+# see bugzilla #8966
+is( $cal->is_holiday($later_dt), 0, 'is holiday for the next test' );
+cmp_ok( $later_dt, 'eq', '2012-09-17T17:30:00', 'Date should be the same after is_holiday' );
+
# example tests for bug report
$cal->clear_weekly_closed_days();