[Koha-patches] [PATCH] Bug 1440: Show a list of holidays. Fix for the date formats.
Garry Collum
gcollum at gmail.com
Fri May 15 13:37:50 CEST 2009
This patch fixes the date formats in the holiday display tables. They are now based on the syspref for date formats.
---
C4/Calendar.pm | 8 +++++++-
.../prog/en/modules/tools/holidays.tmpl | 14 +++++++++-----
tools/holidays.pl | 14 ++++++++++++++
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/C4/Calendar.pm b/C4/Calendar.pm
index 657d4b7..2f1f720 100644
--- a/C4/Calendar.pm
+++ b/C4/Calendar.pm
@@ -104,7 +104,9 @@ sub _init {
while (my $row = $repeatable->fetchrow_hashref) {
my $key = $row->{month} . "/" . $row->{day};
$day_month_holidays{$key}{title} = $row->{title};
- $day_month_holidays{$key}{description} = $row->{description}
+ $day_month_holidays{$key}{description} = $row->{description};
+ $day_month_holidays{$key}{day} = sprintf("%02d", $row->{day});
+ $day_month_holidays{$key}{month} = sprintf("%02d", $row->{month});
}
$self->{'day_month_holidays'} = \%day_month_holidays;
@@ -117,6 +119,8 @@ sub _init {
while (my ($day, $month, $year, $title, $description) = $special->fetchrow) {
$exception_holidays{"$year/$month/$day"}{title} = $title;
$exception_holidays{"$year/$month/$day"}{description} = $description;
+ $exception_holidays{"$year/$month/$day"}{date} =
+ sprintf("%04d-%02d-%02d", $year, $month, $day);
}
$self->{'exception_holidays'} = \%exception_holidays;
@@ -125,6 +129,8 @@ sub _init {
while (my ($day, $month, $year, $title, $description) = $special->fetchrow) {
$single_holidays{"$year/$month/$day"}{title} = $title;
$single_holidays{"$year/$month/$day"}{description} = $description;
+ $single_holidays{"$year/$month/$day"}{date} =
+ sprintf("%04d-%02d-%02d", $year, $month, $day);
}
$self->{'single_holidays'} = \%single_holidays;
return $self;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl
index e3c512f..d8b0e06 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl
@@ -357,7 +357,7 @@ h1 select { width: 20em; }
<h3>Exceptions</h3>
<table id="holidayexceptions">
<thead><tr>
- <th class="exception">Year/Month/Day</th>
+ <th class="exception">Date</th>
<th class="exception">Title</th>
<th class="exception">Description</th>
</tr>
@@ -365,7 +365,7 @@ h1 select { width: 20em; }
<tbody>
<!-- TMPL_LOOP NAME="EXCEPTION_HOLIDAYS_LOOP" -->
<tr>
- <td><!-- TMPL_VAR NAME="KEY" --></td>
+ <td><!-- TMPL_VAR NAME="DATE" --></td>
<td><!-- TMPL_VAR NAME="TITLE" --></td>
<td><!-- TMPL_VAR NAME="DESCRIPTION" --></td>
</tr>
@@ -405,7 +405,11 @@ h1 select { width: 20em; }
<table id="holidaysyearlyrepeatable">
<thead>
<tr>
+ <!-- TMPL_IF EXPR="dateformat eq 'metric'" -->
+ <th class="repeatableday">Day/Month</th>
+ <!-- TMPL_ELSE -->
<th class="repeatableday">Month/Day</th>
+ <!-- /TMPL_IF -->
<th class="repeatableday">Title</th>
<th class="repeatableday">Description</th>
</tr>
@@ -413,7 +417,7 @@ h1 select { width: 20em; }
<tbody>
<!-- TMPL_LOOP NAME="DAY_MONTH_HOLIDAYS_LOOP" -->
<tr>
- <td><!-- TMPL_VAR NAME="KEY" --></td>
+ <td><!-- TMPL_VAR NAME="DATE" --></td>
<td><!-- TMPL_VAR NAME="TITLE" --></td>
<td><!-- TMPL_VAR NAME="DESCRIPTION" --></td>
</tr>
@@ -427,7 +431,7 @@ h1 select { width: 20em; }
<table id="holidaysunique">
<thead>
<tr>
- <th class="holiday">Year/Month/Day</th>
+ <th class="holiday">Date</th>
<th class="holiday">Title</th>
<th class="holiday">Description</th>
</tr>
@@ -435,7 +439,7 @@ h1 select { width: 20em; }
<tbody>
<!-- TMPL_LOOP NAME="HOLIDAYS_LOOP" -->
<tr>
- <td><!-- TMPL_VAR NAME="KEY" --></td>
+ <td><!-- TMPL_VAR NAME="DATE" --></td>
<td><!-- TMPL_VAR NAME="TITLE" --></td>
<td><!-- TMPL_VAR NAME="DESCRIPTION" --></td>
</tr>
diff --git a/tools/holidays.pl b/tools/holidays.pl
index 6cc26fa..d3a450c 100755
--- a/tools/holidays.pl
+++ b/tools/holidays.pl
@@ -76,8 +76,18 @@ foreach my $weekday (keys %$week_days_holidays) {
my $day_month_holidays = $calendar->get_day_month_holidays();
my @day_month_holidays;
foreach my $monthDay (keys %$day_month_holidays) {
+ # Determine date format on month and day.
+ my $day_monthdate;
+ if (C4::Context->preference("dateformat") eq "metric") {
+ $day_monthdate = "$day_month_holidays->{$monthDay}{day}/$day_month_holidays->{$monthDay}{month}";
+ } elsif (C4::Context->preference("dateformat") eq "us") {
+ $day_monthdate = "$day_month_holidays->{$monthDay}{month}/$day_month_holidays->{$monthDay}{day}";
+ } else {
+ $day_monthdate = "$day_month_holidays->{$monthDay}{month}-$day_month_holidays->{$monthDay}{day}";
+ }
my %day_month;
%day_month = (KEY => $monthDay,
+ DATE => $day_monthdate,
TITLE => $day_month_holidays->{$monthDay}{title},
DESCRIPTION => $day_month_holidays->{$monthDay}{description});
push @day_month_holidays, \%day_month;
@@ -86,8 +96,10 @@ foreach my $monthDay (keys %$day_month_holidays) {
my $exception_holidays = $calendar->get_exception_holidays();
my @exception_holidays;
foreach my $yearMonthDay (keys %$exception_holidays) {
+ my $exceptiondate = C4::Dates->new($exception_holidays->{$yearMonthDay}{date}, "iso");
my %exception_holiday;
%exception_holiday = (KEY => $yearMonthDay,
+ DATE => $exceptiondate->output("syspref"),
TITLE => $exception_holidays->{$yearMonthDay}{title},
DESCRIPTION => $exception_holidays->{$yearMonthDay}{description});
push @exception_holidays, \%exception_holiday;
@@ -96,8 +108,10 @@ foreach my $yearMonthDay (keys %$exception_holidays) {
my $single_holidays = $calendar->get_single_holidays();
my @holidays;
foreach my $yearMonthDay (keys %$single_holidays) {
+ my $holidaydate = C4::Dates->new($single_holidays->{$yearMonthDay}{date}, "iso");
my %holiday;
%holiday = (KEY => $yearMonthDay,
+ DATE => $holidaydate->output("syspref"),
TITLE => $single_holidays->{$yearMonthDay}{title},
DESCRIPTION => $single_holidays->{$yearMonthDay}{description});
push @holidays, \%holiday;
--
1.5.6.5
More information about the Koha-patches
mailing list