Skip Menu |

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

Report information
The Basics
Id: 31130
Status: open
Priority: 0/
Queue: DateTime-Calendar-Hebrew

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

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



Subject: Clone fails on floating time zone object?
I had some tests fail (clone.t) while installing DateTime::Calendar::Hebrew The tests seemed to fail in DateTime.pm's from_object() method, if $object->time_zone was 'floating' rather than a TimeZone object. The patch below (and attached) 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. All I did was copy the earlier snippet (setting $self->{tz}) so that if the time_zone is a string it is objectified. ===================================================================== Here is the relevant code from DateTime::Calendar::Hebrew: use DateTime::Calendar::Hebrew; use DateTime::Event::Sunrise; print "1..1\n"; my $sunset = DateTime::Event::Sunrise->sunset ( # Latitude/Longitude for NYC longitude =>'-73.59', latitude =>'40.38', ); # the date the Ancient Israelites left Egypt my $DT = new DateTime::Calendar::Hebrew( year => 2449, month => 1, day => 15, hour => 23, minute => 59, second => 0, nanosecond => 987654321, time_zone => 'America/New_York', sunset => $sunset, ); my $clone = $DT->clone; print Dumper $clone; if($DT->utc_rd_as_seconds == $clone->utc_rd_as_seconds) { print "ok\n"; } else { print "not ok\n"; } exit; ===================================================================== --- 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: clone.t
use DateTime::Calendar::Hebrew; use DateTime::Event::Sunrise; print "1..1\n"; my $sunset = DateTime::Event::Sunrise->sunset ( # Latitude/Longitude for NYC longitude =>'-73.59', latitude =>'40.38', ); # the date the Ancient Israelites left Egypt my $DT = new DateTime::Calendar::Hebrew( year => 2449, month => 1, day => 15, hour => 23, minute => 59, second => 0, nanosecond => 987654321, time_zone => 'America/New_York', sunset => $sunset, ); my $clone = $DT->clone; print Dumper $clone; if($DT->utc_rd_as_seconds == $clone->utc_rd_as_seconds) { print "ok\n"; } else { print "not ok\n"; } exit;
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 ) } =
From: DROLSKY [...] cpan.org
On Sat Dec 01 13:40:11 2007, FLIP wrote: Show quoted text
> I had some tests fail (clone.t) while installing
DateTime::Calendar::Hebrew Show quoted text
> > The tests seemed to fail in DateTime.pm's from_object() method, if > $object->time_zone was 'floating' rather than a TimeZone object. The > patch below (and attached) 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.
It's not really kosher (ha, I slay me!) for the time_zone() method of DT::C::Hebrew to return a string like that. It's not really specified anywhere that this is no good, but it's kind of a common sense thing. Really, DT::C::Hebrew should either implement time zone's for real, or not have such a method.
RT-Send-CC: perl [...] psycomp.com
Steven, I moved this ticket to the DT::Calendar::Hebrew queue, since that's where the bug is. Can you please take ownership of it? Thanks, -dave