Lines 644-650
C<$year> Is the year to check whether if is a holiday or not.
Link Here
|
644 |
sub isHoliday { |
644 |
sub isHoliday { |
645 |
my ($self, $day, $month, $year) = @_; |
645 |
my ($self, $day, $month, $year) = @_; |
646 |
# FIXME - date strings are stored in non-padded metric format. should change to iso. |
646 |
# FIXME - date strings are stored in non-padded metric format. should change to iso. |
647 |
# FIXME - should change arguments to accept C4::Dates object |
|
|
648 |
$month=$month+0; |
647 |
$month=$month+0; |
649 |
$year=$year+0; |
648 |
$year=$year+0; |
650 |
$day=$day+0; |
649 |
$day=$day+0; |
Lines 700-706
sub copy_to_branch {
Link Here
|
700 |
|
699 |
|
701 |
my ($day, $month, $year) = $calendar->addDate($date, $offset) |
700 |
my ($day, $month, $year) = $calendar->addDate($date, $offset) |
702 |
|
701 |
|
703 |
C<$date> is a C4::Dates object representing the starting date of the interval. |
702 |
C<$startdate> is the starting date of the interval. |
704 |
|
703 |
|
705 |
C<$offset> Is the number of days that this function has to count from $date. |
704 |
C<$offset> Is the number of days that this function has to count from $date. |
706 |
|
705 |
|
Lines 708-714
C<$offset> Is the number of days that this function has to count from $date.
Link Here
|
708 |
|
707 |
|
709 |
sub addDate { |
708 |
sub addDate { |
710 |
my ($self, $startdate, $offset) = @_; |
709 |
my ($self, $startdate, $offset) = @_; |
711 |
my ($year,$month,$day) = split("-",$startdate->output('iso')); |
710 |
$startdate = eval { output_pref( { dt => dt_from_string( $startdate ), dateonly => 1, dateformat => 'iso' } ); }; |
|
|
711 |
my ( $year, $month, $day) = split( "-", $startdate ); |
712 |
my $daystep = 1; |
712 |
my $daystep = 1; |
713 |
if ($offset < 0) { # In case $offset is negative |
713 |
if ($offset < 0) { # In case $offset is negative |
714 |
# $offset = $offset*(-1); |
714 |
# $offset = $offset*(-1); |
Lines 730-743
sub addDate {
Link Here
|
730 |
} else { ## ($daysMode eq 'Days') |
730 |
} else { ## ($daysMode eq 'Days') |
731 |
($year, $month, $day) = &Date::Calc::Add_Delta_Days($year, $month, $day, $offset ); |
731 |
($year, $month, $day) = &Date::Calc::Add_Delta_Days($year, $month, $day, $offset ); |
732 |
} |
732 |
} |
733 |
return(C4::Dates->new( sprintf(ISO_DATE_FORMAT,$year,$month,$day),'iso')); |
733 |
my $date_ret = sprintf(ISO_DATE_FORMAT,$year,$month,$day); |
|
|
734 |
$date_ret = eval { output_pref( { dt => dt_from_string( $date_ret), dateonly => 1, dateformat => 'iso' } ); }; |
735 |
return($date_ret); |
734 |
} |
736 |
} |
735 |
|
737 |
|
736 |
=head2 daysBetween |
738 |
=head2 daysBetween |
737 |
|
739 |
|
738 |
my $daysBetween = $calendar->daysBetween($startdate, $enddate) |
740 |
my $daysBetween = $calendar->daysBetween($startdate, $enddate) |
739 |
|
741 |
|
740 |
C<$startdate> and C<$enddate> are C4::Dates objects that define the interval. |
742 |
C<$startdate> and C<$enddate> define the interval. |
741 |
|
743 |
|
742 |
Returns the number of non-holiday days in the interval. |
744 |
Returns the number of non-holiday days in the interval. |
743 |
useDaysMode syspref has no effect here. |
745 |
useDaysMode syspref has no effect here. |
Lines 747-754
sub daysBetween {
Link Here
|
747 |
my $self = shift or return; |
749 |
my $self = shift or return; |
748 |
my $startdate = shift or return; |
750 |
my $startdate = shift or return; |
749 |
my $enddate = shift or return; |
751 |
my $enddate = shift or return; |
750 |
my ($yearFrom,$monthFrom,$dayFrom) = split("-",$startdate->output('iso')); |
752 |
$startdate = eval { output_pref( { dt => dt_from_string( $startdate ), dateonly => 1, dateformat => 'iso' } ); }; |
751 |
my ($yearTo, $monthTo, $dayTo ) = split("-", $enddate->output('iso')); |
753 |
$enddate = eval { output_pref( { dt => dt_from_string( $enddate ), dateonly => 1, dateformat => 'iso' } ); }; |
|
|
754 |
my ( $yearFrom, $monthFrom, $dayFrom) = split( "-", $startdate); |
755 |
my ( $yearTo, $monthTo, $dayTo ) = split( "-", $enddate); |
752 |
if (Date_to_Days($yearFrom,$monthFrom,$dayFrom) > Date_to_Days($yearTo,$monthTo,$dayTo)) { |
756 |
if (Date_to_Days($yearFrom,$monthFrom,$dayFrom) > Date_to_Days($yearTo,$monthTo,$dayTo)) { |
753 |
return 0; |
757 |
return 0; |
754 |
# we don't go backwards ( FIXME - handle this error better ) |
758 |
# we don't go backwards ( FIXME - handle this error better ) |