[Koha-bugs] [Bug 19176] Dates comparison fails on slow server

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Oct 27 15:24:03 CEST 2017


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19176

Julian Maurice <julian.maurice at biblibre.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|Signed Off                  |Failed QA

--- Comment #20 from Julian Maurice <julian.maurice at biblibre.com> ---
There's still something wrong with timezones.

Try this:

$dt_1 = DateTime->new(year => 2001, month => 1, day => 1, hour => 0, minute =>
0, second => 0, time_zone => '+0100');
$dt_3 = DateTime->new(year => 2001, month => 1, day => 1, hour => 1, minute =>
0, second => 0, time_zone => '+0200');
is( DateTime->compare($dt_1, $dt_3), 0 );
is( t::lib::Dates::compare( $dt_1, $dt_3 ), 0 );

$dt_1 and $dt_3 are the exact same time, but with a different timezone.
DateTime->compare returns 0, but t::lib::Dates::Compare returns -1, because it
sets timezone of both date to 'floating' before comparing them, which is wrong
not only because it produces a false result, but also because comparing
DateTime objects shouldn't modify them.

Also a note on this line:

$dt_3 = $dt_1->clone->set_time_zone('+0400');

It doesn't do what you think. After that line, $dt_3 is still equal to $dt_1
(with a different timezone) because set_time_zone also adjusts the local time
(see
http://search.cpan.org/~drolsky/DateTime-1.44/lib/DateTime.pm#$dt-%3Eset_time_zone%28_$tz_%29)

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list