Bug 19176: Reduce the number of seconds to 5
[koha.git] / t / lib / Dates.pm
blob4e0f25faf4b0a1ae21472988ae572ae33dc70bbc
1 package t::lib::Dates;
3 use Modern::Perl;
4 use Test::More;
5 use Koha::DateUtils;
6 use DateTime;
7 =head2 compare
9 compare( $got_dt, $expected_dt, $test_description );
11 Will execute a test and compare the 2 dates given in parameters
12 The date will be compared truncated to minutes
14 =cut
16 sub compare {
17 my ( $got, $expected, $description ) = @_;
18 my $dt_got = dt_from_string($got);
19 my $dt_expected = dt_from_string($expected);
20 $dt_got->set_time_zone('floating');
21 $dt_expected->set_time_zone('floating');
22 my $diff = $dt_got->epoch - $dt_expected->epoch;
23 if ( abs($diff) < 6 ) { return 0 }
24 return $diff > 0 ? 1 : -1;