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

(-)a/tools/exceptionHolidays.pl (-2 / +3 lines)
Lines 10-15 use C4::Output; Link Here
10
use DateTime;
10
use DateTime;
11
11
12
use C4::Calendar;
12
use C4::Calendar;
13
use Koha::DateUtils;
13
14
14
my $input = new CGI;
15
my $input = new CGI;
15
my $dbh = C4::Context->dbh();
16
my $dbh = C4::Context->dbh();
Lines 27-34 my $description = $input->param('showDescription'); Link Here
27
my $holidaytype = $input->param('showHolidayType');
28
my $holidaytype = $input->param('showHolidayType');
28
my $datecancelrange = $input->param('datecancelrange');
29
my $datecancelrange = $input->param('datecancelrange');
29
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
30
my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day);
30
my $isodate = C4::Dates->new($calendardate, 'iso');
31
my $isodate = eval{ dt_from_string( $calendardate ); };
31
$calendardate = $isodate->output('syspref');
32
$calendardate = output_pref( { dt => $isodate, dateonly => 1 } );
32
33
33
my $calendar = C4::Calendar->new(branchcode => $branchcode);
34
my $calendar = C4::Calendar->new(branchcode => $branchcode);
34
35
(-)a/tools/holidays.pl (-12 / +8 lines)
Lines 26-31 use C4::Output; Link Here
26
26
27
use C4::Branch; # GetBranches
27
use C4::Branch; # GetBranches
28
use C4::Calendar;
28
use C4::Calendar;
29
use Koha::DateUtils;
29
30
30
my $input = new CGI;
31
my $input = new CGI;
31
32
Lines 44-58 my ($template, $loggedinuser, $cookie) Link Here
44
my $keydate;
45
my $keydate;
45
# calendardate - date passed in url for human readability (syspref)
46
# calendardate - date passed in url for human readability (syspref)
46
my $calendardate;
47
my $calendardate;
47
my $today = C4::Dates->new();
48
my $calendarinput_dt = eval { dt_from_string( $input->param('calendardate') ); } || dt_from_string;
48
my $calendarinput = C4::Dates->new($input->param('calendardate')) || $today;
49
# if the url has an invalid date default to 'now.'
49
# if the url has an invalid date default to 'now.'
50
unless($calendardate = $calendarinput->output('syspref')) {
50
$calendardate = output_pref( { dt => $calendarinput_dt, dateonly => 1 } );
51
  $calendardate = $today->output('syspref');
51
$keydate = output_pref( { dt => $calendarinput_dt, dateonly => 1, dateformat => 'iso' } );
52
}
53
unless($keydate = $calendarinput->output('iso')) {
54
  $keydate = $today->output('iso');
55
}
56
$keydate =~ s/-/\//g;
52
$keydate =~ s/-/\//g;
57
53
58
my $branch= $input->param('branch') || C4::Context->userenv->{'branch'};
54
my $branch= $input->param('branch') || C4::Context->userenv->{'branch'};
Lines 123-133 foreach my $monthDay (keys %$day_month_holidays) { Link Here
123
my $exception_holidays = $calendar->get_exception_holidays();
119
my $exception_holidays = $calendar->get_exception_holidays();
124
my @exception_holidays;
120
my @exception_holidays;
125
foreach my $yearMonthDay (keys %$exception_holidays) {
121
foreach my $yearMonthDay (keys %$exception_holidays) {
126
    my $exceptiondate = C4::Dates->new($exception_holidays->{$yearMonthDay}{date}, "iso");
122
    my $exceptiondate = eval { dt_from_string( $exception_holidays->{$yearMonthDay}{date} ) };
127
    my %exception_holiday;
123
    my %exception_holiday;
128
    %exception_holiday = (KEY => $yearMonthDay,
124
    %exception_holiday = (KEY => $yearMonthDay,
129
                          DATE_SORT => $exception_holidays->{$yearMonthDay}{date},
125
                          DATE_SORT => $exception_holidays->{$yearMonthDay}{date},
130
                          DATE => $exceptiondate->output("syspref"),
126
                          DATE => output_pref( { dt => $exceptiondate, dateonly => 1, dateformat => 'iso' } ),
131
                          TITLE => $exception_holidays->{$yearMonthDay}{title},
127
                          TITLE => $exception_holidays->{$yearMonthDay}{title},
132
                          DESCRIPTION => $exception_holidays->{$yearMonthDay}{description});
128
                          DESCRIPTION => $exception_holidays->{$yearMonthDay}{description});
133
    push @exception_holidays, \%exception_holiday;
129
    push @exception_holidays, \%exception_holiday;
Lines 136-146 foreach my $yearMonthDay (keys %$exception_holidays) { Link Here
136
my $single_holidays = $calendar->get_single_holidays();
132
my $single_holidays = $calendar->get_single_holidays();
137
my @holidays;
133
my @holidays;
138
foreach my $yearMonthDay (keys %$single_holidays) {
134
foreach my $yearMonthDay (keys %$single_holidays) {
139
    my $holidaydate = C4::Dates->new($single_holidays->{$yearMonthDay}{date}, "iso");
135
    my $holidaydate = eval { dt_from_string( $single_holidays->{$yearMonthDay}{date} ) };
140
    my %holiday;
136
    my %holiday;
141
    %holiday = (KEY => $yearMonthDay,
137
    %holiday = (KEY => $yearMonthDay,
142
                DATE_SORT => $single_holidays->{$yearMonthDay}{date},
138
                DATE_SORT => $single_holidays->{$yearMonthDay}{date},
143
                DATE => $holidaydate->output("syspref"),
139
                DATE => output_pref( { dt => $holidaydate, dateonly => 1, dateformat => 'iso' } ),
144
                TITLE => $single_holidays->{$yearMonthDay}{title},
140
                TITLE => $single_holidays->{$yearMonthDay}{title},
145
                DESCRIPTION => $single_holidays->{$yearMonthDay}{description});
141
                DESCRIPTION => $single_holidays->{$yearMonthDay}{description});
146
    push @holidays, \%holiday;
142
    push @holidays, \%holiday;
(-)a/tools/newHolidays.pl (-4 / +3 lines)
Lines 12-20 use C4::Output; Link Here
12
12
13
use Koha::Cache;
13
use Koha::Cache;
14
14
15
use C4::Dates;
16
use C4::Calendar;
15
use C4::Calendar;
17
use DateTime;
16
use DateTime;
17
use Koha::DateUtils;
18
18
19
my $input               = new CGI;
19
my $input               = new CGI;
20
my $dbh                 = C4::Context->dbh();
20
my $dbh                 = C4::Context->dbh();
Lines 35-42 our $newoperation = $input->param('newOperation'); Link Here
35
my $allbranches         = $input->param('allBranches');
35
my $allbranches         = $input->param('allBranches');
36
36
37
my $calendardate        = sprintf("%04d-%02d-%02d", $year, $month, $day);
37
my $calendardate        = sprintf("%04d-%02d-%02d", $year, $month, $day);
38
my $isodate             = C4::Dates->new($calendardate, 'iso');
38
my $isodate = eval{ dt_from_string( $calendardate ); };
39
$calendardate           = $isodate->output('syspref');
39
$calendardate = output_pref( { dt => $isodate, dateonly => 1 } );
40
40
41
my @dateend = split(/[\/-]/, $dateofrange);
41
my @dateend = split(/[\/-]/, $dateofrange);
42
if (C4::Context->preference("dateformat") eq "metric") {
42
if (C4::Context->preference("dateformat") eq "metric") {
43
- 

Return to bug 14954