mathieu has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I've got a problem following the upgrade from DateTime v0.61 to DateTime v0.70 my custom date module is not working anymore, apparently due to the changes to how the new() method is now called. On this current code, I'm having errors now with v0.70 and none with v0.61 : edt.pm
package edt; use strict; use DateTime; our @ISA = qw/ DateTime /; sub new { my $proto = shift; my $class = ref($proto) || $proto; my %h_p = @_; $h_p{year} = '2011'; my $self = $class->SUPER::new( %h_p ); $self->{_TZONE} = $h_p{time_zone}; return bless($self, $class); } sub custom { print "in custom module\n"; } 1;
edt.pl
use strict; use lib qw( . ); use edt; my $edt = new edt(); print "DateTime::VERSION = ".$DateTime::VERSION."<\n"; print $edt->epoch()."\n"; $edt->custom(); # dies here $edt->from_epoch( epoch => time() );
running perl edt.pl I have :
DateTime::VERSION = 0.70< 1293840000 in custom module Can't locate object method "_normalize_nanoseconds" via package "2011- +01-01T00:00:00" at /usr/lib/perl5/DateTime.pm line 253.
perl -v outputs :
erdev1:/home/eureca/Eulerian-Eureca# perl -v This is perl 5, version 12, subversion 4 (v5.12.4) built for i486-linu +x-gnu-thread-multi-64int (with 46 registered patches, see perl -V for more detail) Copyright 1987-2010, Larry Wall
erdev1:/home/eureca/Eulerian-Eureca# uname -a Linux erdev1 2.6.38-2-686-bigmem #1 SMP Sun May 8 15:43:39 UTC 2011 i6 +86 GNU/Linux
Thanks for your help.

Replies are listed 'Best First'.
Re: Inheritance problem with DateTime version > 0.61
by Anonymous Monk on Oct 13, 2011 at 13:34 UTC

    There is no inheritance problem

    Observe

    $ perl -MDateTime -le " print DateTime->now->from_epoch( epoch => time + ) " Can't locate object method "_normalize_nanoseconds" via package "2011- +10-13T13:33:26" at C:/perl/site/5.14.1/lib/MSWin32-x86-multi-thread/D +ateTime.pm line 253.

    from_epoch is a class method

    If you consider this a bug, report it upstream