X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=Koha%2FCalendar.pm;h=b52ae5fb51875d7cb5d99ae07480f9d7e37b4caa;hb=f37a163e7573ac9dea46c0081ebe43bf37bf92c1;hp=45841beeb9525a9d52c408407117abea6475cbf7;hpb=aa7ac570b2d551ce8c537f0bac31f803c379e6ce;p=koha_fer diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm index 45841beeb9..b52ae5fb51 100644 --- a/Koha/Calendar.pm +++ b/Koha/Calendar.pm @@ -18,10 +18,6 @@ sub new { my $o = lc $o_name; $self->{$o} = $options{$o_name}; } - if ( exists $options{TEST_MODE} ) { - $self->_mockinit(); - return $self; - } if ( !defined $self->{branchcode} ) { croak 'No branchcode argument passed to Koha::Calendar->new'; } @@ -247,6 +243,13 @@ sub days_between { my $start_dt = shift; my $end_dt = shift; + if ( $start_dt->compare($end_dt) > 0 ) { + # swap dates + my $int_dt = $end_dt; + $end_dt = $start_dt; + $start_dt = $int_dt; + } + # start and end should not be closed days my $days = $start_dt->delta_days($end_dt)->delta_days; @@ -290,31 +293,6 @@ sub hours_between { } -sub _mockinit { - my $self = shift; - $self->{weekly_closed_days} = [ 1, 0, 0, 0, 0, 0, 0 ]; # Sunday only - $self->{day_month_closed_days} = { 6 => { 16 => 1, } }; - my $dates = []; - $self->{exception_holidays} = - DateTime::Set->from_datetimes( dates => $dates ); - my $special = DateTime->new( - year => 2011, - month => 6, - day => 1, - time_zone => 'Europe/London', - ); - push @{$dates}, $special; - $self->{single_holidays} = DateTime::Set->from_datetimes( dates => $dates ); - - # if not defined, days_mode defaults to 'Calendar' - if ( !defined($self->{days_mode}) ) { - $self->{days_mode} = 'Calendar'; - } - - $self->{test} = 1; - return; -} - sub set_daysmode { my ( $self, $mode ) = @_;