View | Details | Raw Unified | Return to bug 19176
Collapse All | Expand All

(-)a/t/Test/Dates.t (-1 / +1 lines)
Lines 14-20 is( t::lib::Dates::compare( $dt_2, $dt_1 ), 1, '2018 is after 2017' ); Link Here
14
is( t::lib::Dates::compare( $date_1, $date_2 ), -1, '2017 is before 2018 (strings comparison)' );
14
is( t::lib::Dates::compare( $date_1, $date_2 ), -1, '2017 is before 2018 (strings comparison)' );
15
is( t::lib::Dates::compare( $date_2, $date_1 ), 1,  '2018 is after 2017 (strings comparison)' );
15
is( t::lib::Dates::compare( $date_2, $date_1 ), 1,  '2018 is after 2017 (strings comparison)' );
16
16
17
my $dt_3 = $dt_1->clone->subtract( seconds => 59 );
17
my $dt_3 = $dt_1->clone->subtract( seconds => 5 );
18
is( t::lib::Dates::compare( $dt_1, $dt_3 ),
18
is( t::lib::Dates::compare( $dt_1, $dt_3 ),
19
    0, 'If there is less than 1min, the dates are considered identicals' );
19
    0, 'If there is less than 1min, the dates are considered identicals' );
20
is( t::lib::Dates::compare( $dt_3, $dt_1 ),
20
is( t::lib::Dates::compare( $dt_3, $dt_1 ),
(-)a/t/lib/Dates.pm (-2 / +1 lines)
Lines 20-26 sub compare { Link Here
20
    $dt_got->set_time_zone('floating');
20
    $dt_got->set_time_zone('floating');
21
    $dt_expected->set_time_zone('floating');
21
    $dt_expected->set_time_zone('floating');
22
    my $diff = $dt_got->epoch - $dt_expected->epoch;
22
    my $diff = $dt_got->epoch - $dt_expected->epoch;
23
    if ( abs($diff) < 60 ) { return 0 }
23
    if ( abs($diff) < 6 ) { return 0 }
24
    return $diff > 0 ? 1 : -1;
24
    return $diff > 0 ? 1 : -1;
25
}
25
}
26
26
27
- 

Return to bug 19176