2009/4/2 Anton Berezin <[email protected]>:
> Hi,
>
> It's a bit tricky to say which particular module needs to be changed to fix
> this bug, hence I am not using RT for reporting it. The good part is that
> all candidate modules appear to have the same author. :-)
>
> The test case is as follows:
>
> #! /usr/bin/perl
> use strict;
> use warnings;
>
> use DateTime;
> use DateTime::Duration;
> use DateTime::Span;
> use Data::Dumper;
>
> my $bad_s = DateTime->new(year => 2009, month => 1, day => 12, hour => 1,
> minute => 0, second => 0);
> my $bad_e = DateTime->new(year => 2009, month => 1, day => 12, hour => 6,
> minute => 0, second => 0);
>
> my $bad = DateTime::Span->from_datetimes(start => $bad_s, end => $bad_e);
> my $good = $bad->complement;
>
> my $interest_s = DateTime->new(year => 2009, month => 1, day => 12, hour
> => 4, minute => 30, second => 0);
> my $interest_e = DateTime->new(year => 2009, month => 1, day => 12, hour
> => 5, minute => 0, second => 0);
>
> my $interest = DateTime::Span->from_datetimes(start => $interest_s, end =>
> $interest_e);
>
> my $r = $interest->intersection($good);
>
> my $d = $r->duration;
> print Dumper $d;
>
> my $d0 = DateTime::Duration->new(seconds => 0);
> print Dumper $d0;
>
> I would certainly expect for the duration $d of the empty set $r to be the
> same duration as $d0, that is, zero seconds. Instead it behaves more like
> infinity.
This seems to be caused by a previous DateTime::Span fix that went wrong:
eval {
local $SIG{__DIE__}; # don't want to trap this (rt ticket 5434)
$dur = $_[0]->end->subtract_datetime_absolute( $_[0]->start )
};
(start and end are not defined in this case)
>
> Is that something that you might be interesting in fixing?
yes! thanks for reporting.
Flávio S. Glock
> Thanks,
> \Anton.
> --
> There is no beauty in entropy. -- Eliezer Yudkowsky
>