View | Details | Raw Unified | Return to bug 15260
Collapse All | Expand All

(-)a/Koha/Calendar.pm (-11 / +19 lines)
Lines 217-230 sub addDays { Link Here
217
            if ( $self->is_holiday($base_date) ) {
217
            if ( $self->is_holiday($base_date) ) {
218
                my $dow = $base_date->day_of_week;
218
                my $dow = $base_date->day_of_week;
219
                my $days = $days_duration->in_units('days');
219
                my $days = $days_duration->in_units('days');
220
                my $push_amt = (
220
                # Is it a period based on weeks
221
                    # We're using Dayweek useDaysMode option
221
                my $push_amt = $days_duration % 7 == 0 ?
222
                    $self->{days_mode} eq 'Dayweek' &&
222
                    $self->get_push_amt($base_date) : 1;
223
                    # It's period based on weeks
224
                    $days % 7 == 0 &&
225
                    # It's not a permanently closed day
226
                    !$self->{weekly_closed_days}->[$dow] == 1
227
                ) ? 7 : 1;
228
                if ( $days_duration->is_negative() ) {
223
                if ( $days_duration->is_negative() ) {
229
                    $base_date = $self->prev_open_days($base_date, $push_amt);
224
                    $base_date = $self->prev_open_days($base_date, $push_amt);
230
                } else {
225
                } else {
Lines 237-242 sub addDays { Link Here
237
    return $base_date;
232
    return $base_date;
238
}
233
}
239
234
235
sub get_push_amt {
236
    my ( $self, $base_date) = @_;
237
238
    my $dow = $base_date->day_of_week;
239
    return (
240
        # We're using Dayweek useDaysMode option
241
        $self->{days_mode} eq 'Dayweek' &&
242
        # It's not a permanently closed day
243
        !$self->{weekly_closed_days}->[$dow] == 1
244
    ) ? 7 : 1;
245
}
246
240
sub is_holiday {
247
sub is_holiday {
241
    my ( $self, $dt ) = @_;
248
    my ( $self, $dt ) = @_;
242
249
Lines 285-291 sub next_open_days { Link Here
285
292
286
    $base_date->add(days => $to_add);
293
    $base_date->add(days => $to_add);
287
    while ($self->is_holiday($base_date)) {
294
    while ($self->is_holiday($base_date)) {
288
        $base_date->add(days => $to_add);
295
        my $add_next = $self->get_push_amt($base_date);
296
        $base_date->add(days => $add_next);
289
    }
297
    }
290
    return $base_date;
298
    return $base_date;
291
}
299
}
Lines 301-307 sub prev_open_days { Link Here
301
    $base_date->add(days => $to_sub);
309
    $base_date->add(days => $to_sub);
302
310
303
    while ($self->is_holiday($base_date)) {
311
    while ($self->is_holiday($base_date)) {
304
        $base_date->add(days => $to_sub);
312
        my $sub_next = $self->get_push_amt($base_date);
313
        $base_date->add(days => $sub_next);
305
    }
314
    }
306
315
307
    return $base_date;
316
    return $base_date;
308
- 

Return to bug 15260