X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=t%2Flib%2FDates.pm;h=53400998812c8d14fda3bfe9211d46d1f95c59c9;hb=9d6d641d1f8b77271800f43bc027b651f9aea52b;hp=1aa1adc233a071bf01d89a1b2894b5835eb2a113;hpb=211dafc6505bbaa9bf6bbc4704937e4c7fed4fa2;p=srvgit diff --git a/t/lib/Dates.pm b/t/lib/Dates.pm index 1aa1adc233..5340099881 100644 --- a/t/lib/Dates.pm +++ b/t/lib/Dates.pm @@ -1,8 +1,7 @@ package t::lib::Dates; use Modern::Perl; -use Test::More; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); use DateTime; =head1 NAME @@ -13,21 +12,19 @@ t::lib::Dates.pm - test helper module for working with dates =head2 compare - compare( $got_dt, $expected_dt, $test_description ); + compare( $got_dt, $expected_dt ); Will execute a test and compare the 2 dates given in parameters -The date will be compared truncated to minutes +The dates will be considered as identical if there are less than 5sec between them. =cut sub compare { - my ( $got, $expected, $description ) = @_; + my ( $got, $expected ) = @_; my $dt_got = dt_from_string($got); my $dt_expected = dt_from_string($expected); - $dt_got->set_time_zone('floating'); - $dt_expected->set_time_zone('floating'); my $diff = $dt_got->epoch - $dt_expected->epoch; - if ( abs($diff) < 6 ) { return 0 } + if ( abs($diff) <= 5 ) { return 0 } return $diff > 0 ? 1 : -1; }