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

(-)a/C4/Calendar.pm (-40 lines)
Lines 695-739 sub copy_to_branch { Link Here
695
    return 1;
695
    return 1;
696
}
696
}
697
697
698
=head2 addDate
699
700
    my ($day, $month, $year) = $calendar->addDate($date, $offset)
701
702
C<$startdate> is the starting date of the interval.
703
704
C<$offset> Is the number of days that this function has to count from $date.
705
706
=cut
707
708
sub addDate {
709
    my ($self, $startdate, $offset) = @_;
710
    $startdate = eval { output_pref( { dt => $startdate, dateonly => 1, dateformat => 'iso' } ); };
711
    my ( $year, $month, $day) = split( "-", $startdate );
712
	my $daystep = 1;
713
	if ($offset < 0) { # In case $offset is negative
714
       # $offset = $offset*(-1);
715
		$daystep = -1;
716
    }
717
	my $daysMode = C4::Context->preference('useDaysMode');
718
    if ($daysMode eq 'Datedue') {
719
        ($year, $month, $day) = &Date::Calc::Add_Delta_Days($year, $month, $day, $offset );
720
	 	while ($self->isHoliday($day, $month, $year)) {
721
            ($year, $month, $day) = &Date::Calc::Add_Delta_Days($year, $month, $day, $daystep);
722
        }
723
    } elsif($daysMode eq 'Calendar') {
724
        while ($offset !=  0) {
725
            ($year, $month, $day) = &Date::Calc::Add_Delta_Days($year, $month, $day, $daystep);
726
            if (!($self->isHoliday($day, $month, $year))) {
727
                $offset = $offset - $daystep;
728
			}
729
        }
730
	} else { ## ($daysMode eq 'Days') 
731
        ($year, $month, $day) = &Date::Calc::Add_Delta_Days($year, $month, $day, $offset );
732
    }
733
    my $date_ret = sprintf(ISO_DATE_FORMAT,$year,$month,$day);
734
    return($date_ret);
735
}
736
737
1;
698
1;
738
699
739
__END__
700
__END__
740
- 

Return to bug 14954