Bugzilla – Attachment 44136 Details for
Bug 14954
Remove C4::Dates from holiday related files in folder tools
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14954 - (followup) Remove C4::Dates from holiday related files
Bug-14954---followup-Remove-C4Dates-from-holiday-r.patch (text/plain), 5.03 KB, created by
Marc Véron
on 2015-10-28 23:01:37 UTC
(
hide
)
Description:
Bug 14954 - (followup) Remove C4::Dates from holiday related files
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2015-10-28 23:01:37 UTC
Size:
5.03 KB
patch
obsolete
>From 6d609f552bdf4be0eb3c5daba96f7d65ed7cb77f Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch> >Date: Wed, 28 Oct 2015 23:51:45 +0100 >Subject: [PATCH] Bug 14954 - (followup) Remove C4::Dates from holiday related > files > >Followup for comment #10 > >To test: >- Go to Home > Tools > Calendar >- Add, edit, delete the different types of holidays and exceptions >- git grep 'C4::Calendar' and test such files >- git grep daysBetween to make sure that this sub is not used >- prove t/Calendar.t >--- > C4/Calendar.pm | 36 +----------------------------------- > tools/holidays.pl | 15 +++++++-------- > 2 files changed, 8 insertions(+), 43 deletions(-) > >diff --git a/C4/Calendar.pm b/C4/Calendar.pm >index bf3b96f..92eb6b3 100644 >--- a/C4/Calendar.pm >+++ b/C4/Calendar.pm >@@ -707,7 +707,7 @@ C<$offset> Is the number of days that this function has to count from $date. > > 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 >@@ -731,43 +731,9 @@ sub addDate { > ($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__ >diff --git a/tools/holidays.pl b/tools/holidays.pl >index bec897d..f1739bd 100755 >--- a/tools/holidays.pl >+++ b/tools/holidays.pl >@@ -41,14 +41,13 @@ my ($template, $loggedinuser, $cookie) > 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'}; >@@ -132,11 +131,11 @@ foreach my $yearMonthDay (keys %$exception_holidays) { > 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; >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14954
:
43098
|
43300
|
43410
|
43957
|
44077
|
44136
|
44390
|
44403
|
44585
|
44586
|
44587
|
44588
|
44589
|
44591
|
44592
|
44749
|
44750
|
44751
|
44752
|
44938
|
44939
|
44940
|
44941