From bc9c7ef1e1802011a6a5e172340c56789f31c638 Mon Sep 17 00:00:00 2001 From: Garry Collum Date: Fri, 15 May 2009 07:37:50 -0400 Subject: [PATCH] Bug 1440: Show a list of holidays. Fix for the date formats. This patch fixes the date formats in the holiday display tables. They are now based on the syspref for date formats. Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- 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 657d4b7f5d..2f1f720548 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 46c8c1aa32..5b0b91101d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tmpl @@ -354,7 +354,7 @@ h1 select { width: 20em; }

Exceptions

- + @@ -362,7 +362,7 @@ h1 select { width: 20em; } - + @@ -402,7 +402,11 @@ h1 select { width: 20em; }
Year/Month/DayDate Title Description
+ + + + @@ -410,7 +414,7 @@ h1 select { width: 20em; } - + @@ -424,7 +428,7 @@ h1 select { width: 20em; }
Day/Month Month/Day Title Description
- + @@ -432,7 +436,7 @@ h1 select { width: 20em; } - + diff --git a/tools/holidays.pl b/tools/holidays.pl index 6cc26fa28a..d3a450c42e 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; -- 2.39.5
Year/Month/DayDate Title Description