fixing date display for koha-news
authorJoshua Ferraro <jmf@liblime.com>
Tue, 23 Oct 2007 17:51:56 +0000 (12:51 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Wed, 24 Oct 2007 21:54:18 +0000 (16:54 -0500)
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/NewsChannels.pm
tools/koha-news.pl

index ea361fd..4369da3 100644 (file)
@@ -20,7 +20,7 @@ package C4::NewsChannels;
 use strict;\r
 \r
 use C4::Context;\r
-use C4::Date;\r
+use C4::Dates qw(DHTMLcalendar format_date);\r
 \r
 use vars qw($VERSION @ISA @EXPORT);\r
 \r
@@ -50,7 +50,7 @@ This module provides the functions needed to admin the news channels and its cat
   &news_channels &get_new_channel &del_channels &add_channel &update_channel\r
   &news_channels_categories &get_new_channel_category &del_channels_categories\r
   &add_channel_category &update_channel_category &news_channels_by_category\r
-&add_opac_new &upd_opac_new &del_opac_new &get_opac_new &get_opac_news\r
+  &add_opac_new &upd_opac_new &del_opac_new &get_opac_new &get_opac_news\r
   &add_opac_electronic &upd_opac_electronic &del_opac_electronic &get_opac_electronic &get_opac_electronics\r
 );\r
 \r
@@ -307,6 +307,7 @@ sub get_opac_news {
     my $count = 0;\r
     while (my $row = $sth->fetchrow_hashref) {\r
         if ((($limit) && ($count < $limit)) || (!$limit)) {\r
+                       # format the dates in the user's requested format defined in sysprefs\r
             $row->{'newdate'} = format_date($row->{'newdate'});\r
             $row->{'expirationdate'} = format_date($row->{'expirationdate'});\r
             push @opac_news, $row;\r
@@ -327,8 +328,9 @@ sub get_opac_news {
 sub GetNewsToDisplay {\r
     my $lang = shift;\r
     my $dbh = C4::Context->dbh;\r
+       my $dateformat = C4::Dates->DHTMLcalendar;\r
     my $query = "\r
-     SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate\r
+     SELECT *,DATE_FORMAT(timestamp, '$dateformat') AS newdate\r
      FROM   opac_news\r
      WHERE   (\r
         expirationdate > CURRENT_DATE()\r
@@ -395,7 +397,8 @@ sub get_opac_electronic {
 sub get_opac_electronics {\r
     my ($section, $lang) = @_;\r
     my $dbh = C4::Context->dbh;\r
-    my $query = "SELECT *, DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate FROM opac_electronic";\r
+       my $dateformat = C4::Dates->DHTMLcalendar;\r
+    my $query = "SELECT *, DATE_FORMAT(timestamp, '$dateformat') AS newdate FROM opac_electronic";\r
     if ($lang) {\r
         $query.= " WHERE lang = '" .$lang ."' ";\r
     }\r
index 43dd9dd..e81a808 100755 (executable)
@@ -102,7 +102,7 @@ else {
     
     foreach my $new ( @$opac_news ) {
         next unless $new->{'expirationdate'};
-               $new->{'expirationdate'}=format_date_in_iso($new->{'expirationdate'});
+               #$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;