From 3fbd20d0f4bb3d6f41f367198e3b26c9f26b8607 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 15 Jan 2024 10:43:44 -0300 Subject: [PATCH] Bug 35788: Simplify code We should not load DateUtils and deal with DateTime objects and formatting when we can use the DB for it, using \'NOW()' should be enough. This patch makes that change. To test: 1. Apply the previous patches 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Bookings.t => SUCCESS: Tests pass! 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi --- Koha/Bookings.pm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Koha/Bookings.pm b/Koha/Bookings.pm index 03e59d92658..7f73a73ed34 100644 --- a/Koha/Bookings.pm +++ b/Koha/Bookings.pm @@ -20,7 +20,6 @@ package Koha::Bookings; use Modern::Perl; use Koha::Database; -use Koha::DateUtils qw( dt_from_string ); use Koha::Booking; use base qw(Koha::Objects); @@ -39,22 +38,20 @@ Koha::Bookings - Koha Booking object set class $bookings->filter_by_future; - Will return the bookings starting from now. +Will return the bookings starting from now. =cut sub filter_by_future { my ($self) = @_; - my $now = dt_from_string; - my $dtf = Koha::Database->new->schema->storage->datetime_parser; - return $self->search( { start_date => { '>' => $dtf->format_datetime($now) } } ); + return $self->search( { start_date => { '>' => \'NOW()' } } ); } =head2 Internal Methods =cut -=head3 type +=head3 _type =cut -- 2.43.0