Lines 28-31
sub compare {
Link Here
|
28 |
return $diff > 0 ? 1 : -1; |
28 |
return $diff > 0 ? 1 : -1; |
29 |
} |
29 |
} |
30 |
|
30 |
|
|
|
31 |
=head2 wait_till_midnight |
32 |
|
33 |
$test_duration = 1; |
34 |
t::lib::Dates::wait_till_midnight($test_duration); |
35 |
|
36 |
Some tests that cross midnight wrongly fail. This waits |
37 |
until after midnight to ensure that the failure is not time related. |
38 |
|
39 |
I<test_duration> - The number of minutes the test takes to run |
40 |
rounded up. Most run quickly, so a default |
41 |
of 1 is sufficient when the parameter is |
42 |
not passed. |
43 |
|
44 |
=cut |
45 |
|
46 |
sub wait_till_midnight { |
47 |
my ($test_duration) = @_; |
48 |
$test_duration = $test_duration // 1; |
49 |
my $current_time = DateTime->now(); |
50 |
if ($current_time->hour == 23 && $current_time->minute >= (60-$test_duration)) { |
51 |
while ($current_time->hour == 23) { |
52 |
sleep(60); |
53 |
$current_time = DateTime->now(); |
54 |
} |
55 |
} |
56 |
} |
57 |
|
31 |
1; |
58 |
1; |
32 |
- |
|
|