This bug report is a documented behaviour, but when I
was
investigating it, I found that subtracting
DT::Infinite objects 
gives a strange result ("nan" in diferent places):

---
use DateTime::Infinite;
my $future = DateTime::Infinite::Future->new;
my $past   = DateTime::Infinite::Past->new;
my $dur = $future - $past;
print "Positive: ", join( ' ', $dur->deltas ), "\n";
$dur = $past - $future;
print "Negative: ", join( ' ', $dur->deltas ), "\n";
---
Positive: months inf days inf minutes inf seconds inf
nanoseconds nan
Negative: months -inf days -inf minutes -inf seconds
nan nanoseconds -inf
---

The positive result has "nan" nanoseconds, while the
negative result has "nan" seconds.
"This is perl, v5.8.2 built for i686-linux"

- Flavio S. Glock


Forwarded Message:
> To: "AdminCc of cpan Ticket #5434:"@imss02.pucrs.br
> From: "Guest via RT" <[EMAIL PROTECTED]>
> Subject: [cpan #5434] subtract_datetime and is_zero
being called on inf valu
> Date: Tue, 24 Feb 2004 14:27:27 -0500 (EST)
> -----
> 
> This message about DateTime-Set was sent to you by
guest <> via rt.cpan.org
> 
> Full context and any attached attachments can be
found at:
> <URL:
https://rt.cpan.org/Ticket/Display.html?id=5434 >
> 
> Using DateTime::SpanSet with an infinite end time
in a set causes a __DIE__ signal handler
to display the following errors:
> 
> errhandler: Can't locate object method
"subtract_datetime" via package "inf" (perhaps you
forgot to load "inf"?) at
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/DateTime.pm
line 1107.
> errhandler: Can't locate object method
"subtract_datetime" via package "inf" (perhaps you
forgot to load "inf"?) at
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/DateTime.pm
line 1107.
> errhandler: Can't locate object method "is_zero"
via package "inf" (perhaps you forgot to
load "inf"?) at testspan.pl line 16.
> Can't locate object method "is_zero" via package
"inf" (perhaps you forgot to load "inf"?)
at testspan.pl line 16.
> 
> The following code will reproduce this error.
> 
> #!/usr/bin/perl -w
> 
> use strict;
> use DateTime;
> use DateTime::Span;
> use DateTime::SpanSet;
> use errhandler;
> 
> $SIG{__DIE__} = sub { warn "errhandler: @_" };
> 
> my $dt   = DateTime->now(time_zone => 'local');
> my $dts  = DateTime::Span->from_datetimes(start =>
$dt);
> my $dtss = DateTime::SpanSet->from_spans(spans =>
[$dts]);
> 
> if ( UNIVERSAL::can($dtss->duration => 'is zero')
){ print "can\n"; }
> $dtss->duration->is_zero;
> 
> Current Distribution: DateTime-Set-0.12.tar.gz
> 
..


Reply via email to