From 8b0a28acedc90480b25cf7823269ddade10392ff Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Mon, 22 Oct 2007 16:43:20 -0500 Subject: [PATCH] fixing koha-news bugs 1508 also refactored to use Dates.pm --- .../prog/en/modules/tools/koha-news.tmpl | 2 +- tools/koha-news.pl | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl index f45896a0ac..5209283930 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tmpl @@ -52,7 +52,7 @@ Edit News ItemAdd News Item
  • - + " /> diff --git a/tools/koha-news.pl b/tools/koha-news.pl index 76e10935bd..43dd9dd5b9 100755 --- a/tools/koha-news.pl +++ b/tools/koha-news.pl @@ -26,7 +26,7 @@ use CGI; use C4::Auth; use C4::Koha; use C4::Context; -use C4::Date; +use C4::Dates qw(format_date_in_iso); use C4::Output; use C4::NewsChannels; use C4::Languages; @@ -37,7 +37,7 @@ my $cgi = new CGI; my $id = $cgi->param('id'); my $title = $cgi->param('title'); my $new = $cgi->param('new'); -my $expirationdate = $cgi->param('expirationdate'); +my $expirationdate = format_date_in_iso($cgi->param('expirationdate')); my $number = $cgi->param('number'); my $lang = $cgi->param('lang'); @@ -102,12 +102,11 @@ else { foreach my $new ( @$opac_news ) { next unless $new->{'expirationdate'}; - # next if $new->{'expirationdate'} eq '0000-00-00'; # now saved as null - $new->{'expirationdate'}=format_date_in_iso($new->{'expirationdate'}); - my @date = split (/-/,$new->{'expirationdate'}); - if ($date[0]*$date[1]*$date[2]>0 && Date_to_Days( @date ) < Date_to_Days(&Today) ){ - $new->{'hasexpirated'} = 1; - } + $new->{'expirationdate'}=format_date_in_iso($new->{'expirationdate'}); + my @date = split (/-/,$new->{'expirationdate'}); + if ($date[0]*$date[1]*$date[2]>0 && Date_to_Days( @date ) < Date_to_Days(&Today) ){ + $new->{'hasexpirated'} = 1; + } } $template->param( @@ -117,6 +116,6 @@ else { ); } $template->param( - DHTMLcalendar_dateformat => get_date_format_string_for_DHTMLcalendar(C4::Context->preference('dateformat')) , + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), ); output_html_with_http_headers $cgi, $cookie, $template->output; -- 2.39.5