Bug Fixing : Forcing USMARC format for xml
[koha.git] / C4 / NewsChannels.pm
index 7e2fdd9..ec222ba 100644 (file)
@@ -20,14 +20,22 @@ package C4::NewsChannels;
 use strict;
 
 use C4::Context;
-use C4::Date;
+use C4::Dates qw(format_date);
 
 use vars qw($VERSION @ISA @EXPORT);
 
-# set the version for version checking
-$VERSION = do { my @v = '$Revision$' =~ /\d+/g;
-    shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
-};
+BEGIN { 
+       $VERSION = 3.01;        # set the version for version checking
+       @ISA = qw(Exporter);
+       @EXPORT = qw(
+               &GetNewsToDisplay
+               &news_channels &get_new_channel &del_channels &add_channel &update_channel
+               &news_channels_categories &get_new_channel_category &del_channels_categories
+               &add_channel_category &update_channel_category &news_channels_by_category
+               &add_opac_new &upd_opac_new &del_opac_new &get_opac_new &get_opac_news
+               &add_opac_electronic &upd_opac_electronic &del_opac_electronic &get_opac_electronic &get_opac_electronics
+       );
+}
 
 =head1 NAME
 
@@ -41,20 +49,6 @@ This module provides the functions needed to admin the news channels and its cat
 
 =over 2
 
-=cut
-
-
-@ISA = qw(Exporter);
-@EXPORT = qw(
-  &GetNewsToDisplay
-  &news_channels &get_new_channel &del_channels &add_channel &update_channel
-  &news_channels_categories &get_new_channel_category &del_channels_categories
-  &add_channel_category &update_channel_category &news_channels_by_category
-&add_opac_new &upd_opac_new &del_opac_new &get_opac_new &get_opac_news
-  &add_opac_electronic &upd_opac_electronic &del_opac_electronic &get_opac_electronic &get_opac_electronics
-);
-
-
 =item news_channels
 
   ($count, @channels) = &news_channels($channel_name, $id_category, $unclassified);
@@ -327,8 +321,9 @@ sub get_opac_news {
 sub GetNewsToDisplay {
     my $lang = shift;
     my $dbh = C4::Context->dbh;
+    # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate
     my $query = "
-     SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate
+     SELECT *,timestamp AS newdate
      FROM   opac_news
      WHERE   (
         expirationdate > CURRENT_DATE()
@@ -337,11 +332,12 @@ sub GetNewsToDisplay {
       )
       AND   lang = ?
       ORDER BY number
-    ";
+    ";                         # expirationdate field is NOT in ISO format?
     my $sth = $dbh->prepare($query);
     $sth->execute($lang);
     my @results;
     while ( my $row = $sth->fetchrow_hashref ){
+               $row->{newdate} = format_date($row->{newdate});
         push @results, $row;
     }
     return \@results;
@@ -410,14 +406,14 @@ sub get_opac_electronics {
     my $count = 0;
     while (my $row = $sth->fetchrow_hashref) {
             push @opac_electronic, $row;
-
-    
         $count++;
     }
 
     return ($count,\@opac_electronic);
 }
-END { }    # module clean-up code here (global destructor)
+
+1;
+__END__
 
 =back