Skip Menu |

This queue is for tickets about the DateTime-Calendar-Hebrew CPAN distribution.

Report information
The Basics
Id: 31131
Status: new
Priority: 0/
Queue: DateTime-Calendar-Hebrew

People
Owner: Nobody in particular
Requestors: FLIP [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.04
Fixed in: (no value)



Subject: Compare (in overload.t and durations.t) warn with undef nanoseconds, and clone.t fails without use Dumper;
I had some tests fail while installing DateTime::Calendar::Hebrew One failure was in clone.t. The test failed complaining about Dumper: t/clone..............Name "main::Dumper" used only once: possible typo at t/clone.t line 25. print() on unopened filehandle Dumper at t/clone.t line 25. I just added "use Data::Dumper;" to the top and this went away. The clone.t test then failed in DateTime.pm's from_object() method, complaining about the 'floating' method. I suspect this may be a problem in DateTime.pm, and have submitted a patch there (see bug http://rt.cpan.org//Ticket/Display.html?id=31130), or attached. All I did was copy the earlier snippet (setting $self->{tz}) so that if the time_zone is a string it is objectified. The patch seemed to quash the error -- I don't actually know if this is a problem with the DateTime.pm code or the DateTime::Calendar::Hebrew code but here it is. The other failures were identical, in overload.t and durations.t, in the compare() method of Hebrew.pm: Use of uninitialized value in numeric ne (!=) at Hebrew.pm line 222. The error happened because the utc_rd_values method was returning 'undef' for the nanoseconds. I simply coerced undef to zero with a line $a[2]||=0; $b[2]||=0; Which again made the error go away. ===================================================================== Patch to Hebrew: diff -Nurw ../DateTime-Calendar-Hebrew-0.04/Hebrew.pm ../DateTime-Calendar-Hebrew-0.04-fix/Hebrew.pm --- ../DateTime-Calendar-Hebrew-0.04/Hebrew.pm 2003-10-02 11:13:18.000000000 -0500 +++ ../DateTime-Calendar-Hebrew-0.04-fix/Hebrew.pm 2007-12-01 11:54:44.985197901 -0600 @@ -218,6 +218,8 @@ my @a = $a->utc_rd_values; my @b = $b->utc_rd_values; + # forgive undefined nanoseconds + $a[2]||=0; $b[2]||=0; foreach my $i (0..2) { return ($a[$i] <=> $b[$i]) if($a[$i] != $b[$i]); } diff -Nurw ../DateTime-Calendar-Hebrew-0.04/t/clone.t ../DateTime-Calendar-Hebrew-0.04-fix/t/clone.t --- ../DateTime-Calendar-Hebrew-0.04/t/clone.t 2007-12-01 12:43:44.226620277 -0600 +++ ../DateTime-Calendar-Hebrew-0.04-fix/t/clone.t 2007-12-01 12:25:30.393863394 -0600 @@ -1,5 +1,7 @@ +use DateTime; use DateTime::Calendar::Hebrew; use DateTime::Event::Sunrise; +use Data::Dumper; print "1..1\n"; my $sunset = DateTime::Event::Sunrise->sunset ( ===================================================================== Patch to DateTime: --- DateTime.pm 2007-09-10 10:41:27.000000000 -0500 +++ DateTime-fix.pm 2007-12-01 12:13:37.037559308 -0600 @@ -509,13 +509,21 @@ # on the given value. If the object _is_ on a leap second, we'll # add that to the generated seconds value later. my $leap_seconds = 0; - if ( $object->can('time_zone') && ! $object->time_zone->is_floating + + if ( $object->can('time_zone') ) { + my $tz = + ( ref $object->time_zone ? + $object->time_zone : + DateTime::TimeZone->new( name => $object->time_zone ) + ); + + if ( ! $tz->is_floating && $rd_secs > 86399 && $rd_secs <= $class->_day_length($rd_days) ) { $leap_seconds = $rd_secs - 86399; $rd_secs -= $leap_seconds; } - + } my %args; @args{ qw( year month day ) } = $class->_rd2ymd($rd_days); @args{ qw( hour minute second ) } =
Subject: DateTime-patch.pm
--- DateTime.pm 2007-09-10 10:41:27.000000000 -0500 +++ DateTime-fix.pm 2007-12-01 12:13:37.037559308 -0600 @@ -509,13 +509,21 @@ # on the given value. If the object _is_ on a leap second, we'll # add that to the generated seconds value later. my $leap_seconds = 0; - if ( $object->can('time_zone') && ! $object->time_zone->is_floating + + if ( $object->can('time_zone') ) { + my $tz = + ( ref $object->time_zone ? + $object->time_zone : + DateTime::TimeZone->new( name => $object->time_zone ) + ); + + if ( ! $tz->is_floating && $rd_secs > 86399 && $rd_secs <= $class->_day_length($rd_days) ) { $leap_seconds = $rd_secs - 86399; $rd_secs -= $leap_seconds; } - + } my %args; @args{ qw( year month day ) } = $class->_rd2ymd($rd_days); @args{ qw( hour minute second ) } =
Subject: Hebrew.patch
diff -Nurw ../DateTime-Calendar-Hebrew-0.04/Hebrew.pm ../DateTime-Calendar-Hebrew-0.04-fix/Hebrew.pm --- ../DateTime-Calendar-Hebrew-0.04/Hebrew.pm 2003-10-02 11:13:18.000000000 -0500 +++ ../DateTime-Calendar-Hebrew-0.04-fix/Hebrew.pm 2007-12-01 11:54:44.985197901 -0600 @@ -218,6 +218,8 @@ my @a = $a->utc_rd_values; my @b = $b->utc_rd_values; + # forgive undefined nanoseconds + $a[2]||=0; $b[2]||=0; foreach my $i (0..2) { return ($a[$i] <=> $b[$i]) if($a[$i] != $b[$i]); } diff -Nurw ../DateTime-Calendar-Hebrew-0.04/t/clone.t ../DateTime-Calendar-Hebrew-0.04-fix/t/clone.t --- ../DateTime-Calendar-Hebrew-0.04/t/clone.t 2007-12-01 12:43:44.226620277 -0600 +++ ../DateTime-Calendar-Hebrew-0.04-fix/t/clone.t 2007-12-01 12:25:30.393863394 -0600 @@ -1,5 +1,7 @@ +use DateTime; use DateTime::Calendar::Hebrew; use DateTime::Event::Sunrise; +use Data::Dumper; print "1..1\n"; my $sunset = DateTime::Event::Sunrise->sunset (