Skip to content

Instantly share code, notes, and snippets.

@bessarabov
Last active August 29, 2015 14:04
Show Gist options
  • Save bessarabov/3cdc4079c59b4fe55d38 to your computer and use it in GitHub Desktop.
Save bessarabov/3cdc4079c59b4fe55d38 to your computer and use it in GitHub Desktop.
use strict;
use warnings FATAL => 'all';
use Test::More;
use qbit;
pass('Loaded ok');
# left argument is less than right argument -1
is(
compare_dates('1980-01-01', '1984-07-04', iformat1 => 'db', iformat2 => 'db'),
-1,
'compare_dates()',
);
is(
compare_dates('2000-01-01', '2010-01-01', iformat1 => 'db', iformat2 => 'db'),
-1,
'compare_dates()',
);
=begin comment
The next test is borken. compare_dates() returns 1, while it is expected to
return -1
It works this way because of wrong conversion:
trdate('db' => 'sec', '1900-01-01')
This trdate return 946674000 but it has to return negative number.
=end comment
=cut
is(
compare_dates('1900-01-01', '1984-07-04', iformat1 => 'db', iformat2 => 'db'),
-1,
'compare_dates()',
);
# left argument is equal to right argument 0
is(
compare_dates('2010-01-01', '2010-01-01', iformat1 => 'db', iformat2 => 'db'),
0,
'compare_dates()',
);
# left argument is greater than right argument 1
is(
compare_dates('1999-01-01', '1998-01-01', iformat1 => 'db', iformat2 => 'db'),
1,
'compare_dates()',
);
done_testing();
@sergei-svistunov
Copy link

https://docs.google.com/gview?url=http://it-ebooks.info/read.php?id%3D819-1405437444-995d36a386b63721d0b15a869b4c673c&chrome=true
Page 241 (214) - Jiffies Wraparound.
It isn't the same problem, but it can help, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment