Bug 15823: Can still access patron discharge slip without having the syspref on
[koha.git] / opac / opac-showreviews.pl
index 2bca5d6..628fec8 100755 (executable)
@@ -5,18 +5,18 @@
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use strict;
 use warnings;
@@ -28,8 +28,8 @@ use C4::Output;
 use C4::Circulation;
 use C4::Review;
 use C4::Biblio;
-use C4::Dates;
 use C4::Members qw/GetMemberDetails/;
+use Koha::DateUtils;
 use POSIX qw(ceil strftime);
 
 my $template_name;
@@ -57,8 +57,8 @@ my ( $template, $borrowernumber, $cookie ) = &get_template_and_user(
 );
 
 if($format eq "rss"){
-    my $lastbuilddate = C4::Dates->new();
-    my $lastbuilddate_output = $lastbuilddate->output("rfc822");
+    my $lastbuilddate = dt_from_string;
+    my $lastbuilddate_output = $lastbuilddate->strftime("%a, %d %b %Y %H:%M:%S %z");
     $template->param(
         rss => 1,
         timestamp => $lastbuilddate_output
@@ -114,8 +114,9 @@ for my $result (@$reviews){
        }
 
     if($format eq "rss"){
-        my $rsstimestamp = C4::Dates->new($result->{datereviewed},"iso");
-        my $rsstimestamp_output = $rsstimestamp->output("rfc822");
+        my $rsstimestamp = eval { dt_from_string( $result->{datereviewed} ); };
+        $rsstimestamp = dt_from_string unless ( $rsstimestamp ); #default to today if something went wrong
+        my $rsstimestamp_output = $rsstimestamp->strftime("%a, %d %b %Y %H:%M:%S %z");
         $result->{timestamp} = $rsstimestamp_output;
     }
 }