From 5e1a5b3730ee880b6b42fe6e365113957c264c9c Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Mon, 8 May 2017 21:23:22 +0000
Subject: [PATCH] Bug 18557 [QA Followup] - Use dt_from_string

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
---
 Koha/Clubs.pm | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/Koha/Clubs.pm b/Koha/Clubs.pm
index 677408df3a..eeaf4ef337 100644
--- a/Koha/Clubs.pm
+++ b/Koha/Clubs.pm
@@ -22,6 +22,7 @@ use Modern::Perl;
 use Carp;
 
 use Koha::Database;
+use Koha::DateUtils qw( dt_from_string );
 
 use Koha::Club;
 
@@ -56,10 +57,18 @@ sub get_enrollable {
         }
     }
 
+    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
+
     # Only clubs with no end date or an end date in the future can be enrolled in
     $params->{'-and'} = [
-        -or => [ date_end => { '>=' => \'CAST(now() AS date)' }, date_end => undef],
-        -or => [ 'me.branchcode' => $borrower->branchcode, 'me.branchcode' => undef ]
+        -or => [
+            date_end => { '>=' => $dtf->format_datetime( dt_from_string() ) },
+            date_end => undef,
+        ],
+        -or => [
+            'me.branchcode' => $borrower->branchcode,
+            'me.branchcode' => undef,
+        ]
     ];
 
     my $rs = $self->_resultset()->search( $params, { prefetch => 'club_template' } );
-- 
2.11.0