Strange errors when trying to fix DateTime::Event::Nameday
Ok, I am trying to fix the broken tests in DateTime::Event::NameDay and am getting the error 'Span cannot start after the end in DateTime::Span->from_datetimes'. However my span looks perfectly valid... So I boiled it down to a simple test case: -- #!/usr/local/lib/perl -w use strict; use DateTime; use DateTime::Span; use DateTime::Calendar::Christian; my $dt1 = DateTime->new ( year => 1752, month => 1, day=> 1, ); my $dt2 = DateTime::Calendar::Christian->new ( year => 1755, month => 1, day=> 3, reform_date => $dt1, ); my $sp = DateTime::Span->new(start => $dt1, end => $dt2); -- This gives me two types of error: -- Use of uninitialized value in numeric ne (!=) at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/DateTime.pm line 1174. Use of uninitialized value in numeric comparison (<=>) at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/DateTime.pm line 1174. Span cannot start after the end in DateTime::Span->from_datetimes -- What am I doing wrong? (This is using the latest CVS versions of things) and the relevant lines from DateTime.pm are: -- (> marks line 1174). foreach my $component ( qw( utc_rd_days utc_rd_secs rd_nanosecs ) ) { >return $dt1->{$component} <=> $dt2->{$component} if $dt1->{$component} != $dt2->{$component}; } -- Thanks, -ben
Re: Strange errors when trying to fix DateTime::Event::Nameday
Ben Bennett schreef: > Use of uninitialized value in numeric ne (!=) at > /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/DateTime.pm line 1174. > Use of uninitialized value in numeric comparison (<=>) at > /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/DateTime.pm line 1174. > Span cannot start after the end in DateTime::Span->from_datetimes This is the same problem that I mentioned a few days ago: DateTime::compare cannot compare a DateTime object with a DateTime::Calendar::Christian object. > foreach my $component ( qw( utc_rd_days utc_rd_secs rd_nanosecs ) ) > { > >return $dt1->{$component} <=> $dt2->{$component} > if $dt1->{$component} != $dt2->{$component}; > } This assumes that all objects are hash references, with utc_rd_days etc. as keys. DT::C::Christian is built differently. As the error is probably not in your module, just put this test in a TODO block; then at least we can install it. I can see three solutions: 1) apply the patch to DateTime that I sent a few days ago, so that the output of utc_rd_values is tested; not the hash values directly; 2) do a DT->from_object(object=>$dt2) unless ref($dt2) eq 'DateTime' somewhere in DT::compare; 3) in DT:Span, all dates should be converted to DateTime objects. 4) DT::Span should document that it takes only DT objects, and no other calendars are allowed. In that case, the DT::E::NameDay test is invalid and should be changed. I prefer solution 1 or 2. Eugene -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post