sub addDate {
my ($self, $startdate, $offset) = @_;
- $startdate = eval { output_pref( { dt => dt_from_string( $startdate ), dateonly => 1, dateformat => 'iso' } ); };
+ $startdate = eval { output_pref( { dt => $startdate, dateonly => 1, dateformat => 'iso' } ); };
my ( $year, $month, $day) = split( "-", $startdate );
my $daystep = 1;
if ($offset < 0) { # In case $offset is negative
($year, $month, $day) = &Date::Calc::Add_Delta_Days($year, $month, $day, $offset );
}
my $date_ret = sprintf(ISO_DATE_FORMAT,$year,$month,$day);
- $date_ret = eval { output_pref( { dt => dt_from_string( $date_ret), dateonly => 1, dateformat => 'iso' } ); };
return($date_ret);
}
-=head2 daysBetween
-
- my $daysBetween = $calendar->daysBetween($startdate, $enddate)
-
-C<$startdate> and C<$enddate> define the interval.
-
-Returns the number of non-holiday days in the interval.
-useDaysMode syspref has no effect here.
-=cut
-
-sub daysBetween {
- my $self = shift or return;
- my $startdate = shift or return;
- my $enddate = shift or return;
- $startdate = eval { output_pref( { dt => dt_from_string( $startdate ), dateonly => 1, dateformat => 'iso' } ); };
- $enddate = eval { output_pref( { dt => dt_from_string( $enddate ), dateonly => 1, dateformat => 'iso' } ); };
- my ( $yearFrom, $monthFrom, $dayFrom) = split( "-", $startdate);
- my ( $yearTo, $monthTo, $dayTo ) = split( "-", $enddate);
- if (Date_to_Days($yearFrom,$monthFrom,$dayFrom) > Date_to_Days($yearTo,$monthTo,$dayTo)) {
- return 0;
- # we don't go backwards ( FIXME - handle this error better )
- }
- my $count = 0;
- while (1) {
- ($yearFrom != $yearTo or $monthFrom != $monthTo or $dayFrom != $dayTo) or last; # if they all match, it's the last day
- unless ($self->isHoliday($dayFrom, $monthFrom, $yearFrom)) {
- $count++;
- }
- ($yearFrom, $monthFrom, $dayFrom) = &Date::Calc::Add_Delta_Days($yearFrom, $monthFrom, $dayFrom, 1);
- }
- return($count);
-}
-
1;
__END__
debug => 1,
});
-# keydate - date passed to calendar.js. calendar.js does not process dashes within a date.
-my $keydate;
# calendardate - date passed in url for human readability (syspref)
-my $calendardate;
-my $calendarinput_dt = eval { dt_from_string( $input->param('calendardate') ); } || dt_from_string;
# if the url has an invalid date default to 'now.'
-$calendardate = output_pref( { dt => $calendarinput_dt, dateonly => 1 } );
-$keydate = output_pref( { dt => $calendarinput_dt, dateonly => 1, dateformat => 'iso' } );
+my $calendarinput_dt = eval { dt_from_string( $input->param('calendardate') ); } || dt_from_string;
+my $calendardate = output_pref( { dt => $calendarinput_dt, dateonly => 1 } );
+
+# keydate - date passed to calendar.js. calendar.js does not process dashes within a date.
+my $keydate = output_pref( { dt => $calendarinput_dt, dateonly => 1, dateformat => 'iso' } );
$keydate =~ s/-/\//g;
my $branch= $input->param('branch') || C4::Context->userenv->{'branch'};
my $single_holidays = $calendar->get_single_holidays();
my @holidays;
foreach my $yearMonthDay (keys %$single_holidays) {
- my $holidaydate = eval { dt_from_string( $single_holidays->{$yearMonthDay}{date} ) };
+ my $holidaydate_dt = eval { dt_from_string( $single_holidays->{$yearMonthDay}{date} ) };
my %holiday;
%holiday = (KEY => $yearMonthDay,
DATE_SORT => $single_holidays->{$yearMonthDay}{date},
- DATE => output_pref( { dt => $holidaydate, dateonly => 1, dateformat => 'iso' } ),
+ DATE => output_pref( { dt => $holidaydate_dt, dateonly => 1 } ),
TITLE => $single_holidays->{$yearMonthDay}{title},
DESCRIPTION => $single_holidays->{$yearMonthDay}{description});
push @holidays, \%holiday;