Jonathan Druart
f0e737f43a
Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
27 lines
651 B
Perl
27 lines
651 B
Perl
package t::lib::Dates;
|
|
|
|
use Modern::Perl;
|
|
use Test::More;
|
|
use Koha::DateUtils;
|
|
use DateTime;
|
|
=head2 compare
|
|
|
|
compare( $got_dt, $expected_dt, $test_description );
|
|
|
|
Will execute a test and compare the 2 dates given in parameters
|
|
The date will be compared truncated to minutes
|
|
|
|
=cut
|
|
|
|
sub compare {
|
|
my ( $got, $expected, $description ) = @_;
|
|
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 }
|
|
return $diff > 0 ? 1 : -1;
|
|
}
|
|
|
|
1;
|