From 629598704a4ded9425293340bf5b9de8e347bd68 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 20 Oct 2017 16:04:04 -0300 Subject: [PATCH] Bug 16187: Do not use DateTime directly Koha::DateUtils takes care of what you need Signed-off-by: Jonathan Druart --- Koha/Hold.pm | 2 +- t/db_dependent/Hold.t | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index c30649d459..84117a5f9e 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -58,7 +58,7 @@ my $age = $hold->age( $use_calendar ); sub age { my ( $self, $use_calendar ) = @_; - my $today = DateTime->now(time_zone => C4::Context->tz ); + my $today = dt_from_string; my $age; if ( $use_calendar ) { diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t index 10b8737bff..7eb04abd5e 100755 --- a/t/db_dependent/Hold.t +++ b/t/db_dependent/Hold.t @@ -78,7 +78,7 @@ $hold->store(); my $b1_cal = C4::Calendar->new( branchcode => $branches[1]->{branchcode} ); $b1_cal->insert_single_holiday( day => 02, month => 01, year => 2017, title => "Morty Day", description => "Rick" ); #Add a holiday -my $today = DateTime->now(time_zone => C4::Context->tz ); +my $today = dt_from_string; is( $hold->age(), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days') , "Age of hold is days from reservedate to now if calendar ignored"); is( $hold->age(1), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days' ) - 1 , "Age of hold is days from reservedate to now minus 1 if calendar used"); -- 2.39.5