Bug 16187: Do not use DateTime directly
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 20 Oct 2017 19:04:04 +0000 (16:04 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 20 Oct 2017 19:51:25 +0000 (16:51 -0300)
Koha::DateUtils takes care of what you need

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/Hold.pm
t/db_dependent/Hold.t

index c30649d..84117a5 100644 (file)
@@ -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 ) {
index 10b8737..7eb04ab 100755 (executable)
@@ -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");