On Thu, 29 May 2003, Ben Bennett wrote: > Actually there are two bugs (yes my sandbox is current). > > The first is fixed by the patch below (it creates an unused $tmp > DateTime::Span object without the required args). > > The second is more tricky... DT::Span tries to create a DT::Set > object, but doesn't use DT::Set. This is nasty to fix since DT::Set > uses DT::Span, so you don't want to make a circular dependency. I am > not sure how best to fix this.
There's no such thing as a circular dependency in Perl. Two modules can use each other. > A script to catch this is: > > --- > use DateTime; > use DateTime::Span; > > my $low_date = DateTime->new(year => 2002, month => 3, day => 1); > my $high_date = DateTime->new(year => 2002, month => 2, day => 11); > my $test_date = DateTime->new(year => 2002, month => 2, day => 23); > > # Make sure the high is higher than the low > ($low_date, $high_date) = ($high_date, $low_date) > if $low_date > $high_date; > > # Make the span (note that we don't need to flip the dates) > my $span = DateTime::Span->from_datetimes(start => $low_date, > end => $high_date); > > if ($span->contains($test_date)) { > print '$test_date is between the given dates'; > } I fixed this. > Index: lib/DateTime/Span.pm > =================================================================== > RCS file: /cvsroot/perl-date-time/modules/DateTime-Set/lib/DateTime/Span.pm,v > retrieving revision 1.20 > diff -u -r1.20 Span.pm > --- lib/DateTime/Span.pm 8 May 2003 00:35:32 -0000 1.20 > +++ lib/DateTime/Span.pm 30 May 2003 02:36:20 -0000 > @@ -159,7 +159,7 @@ > sub intersects { > my ($set1, $set2) = @_; > my $class = ref($set1); > - my $tmp = $class->new(); > + my $tmp = {}; # $class->new(); > $set2 = DateTime::Set->new( dates => [ $set2 ] ) unless $set2->can( 'union' ); > return $set1->{set}->intersects( $set2->{set} ); > } > @@ -167,7 +167,7 @@ > sub contains { > my ($set1, $set2) = @_; > my $class = ref($set1); > - my $tmp = $class->new(); > + my $tmp = {}; # $class->new(); > $set2 = DateTime::Set->new( dates => [ $set2 ] ) unless $set2->can( 'union' ); > return $set1->{set}->contains( $set2->{set} ); > } You'll note $tmp was not used at all. I removed it. -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/