Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 117431
Status: rejected
Priority: 0/
Queue: DateTime-TimeZone

People
Owner: Nobody in particular
Requestors: don [...] beusee.com
Cc:
AdminCc:

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



Subject: Fwd: DateTime::TimeZone giving error Can't locate object method "offset_as_string"
Date: Fri, 2 Sep 2016 00:56:03 -0700
To: bug-DateTime-TimeZone [...] rt.cpan.org
From: Don Beusee <don [...] beusee.com>
Hi, I was trying to install the latest bugzilla, which uses this package, and I found the behavior difficult to troubleshoot. See the below email chain and the simple perl program I used to troubleshoot the issue. My simple test program (see the email chain below) was getting: Can't locate object method "offset_as_string" via package "DateTime::TimeZone::Tzfile" at test.pl line 25. I finally narrowed down the error was due to my linux (fedora 23) system didn't have the timezone location defined, even though the date command returned the proper timezone (PDT). My suggestion is that when this package cannot determine the location, give a more meaningful error about the need to configure the timezone *location*. Thanks, -Don ------------------------------------------------------------------------ *From:* Don Beusee *Sent:* Tuesday, August 30, 2016 7:15PM *To:* Support-bugzilla *Subject:* Re: Installing recent versions of bugzilla giving error Can't locate object method "offset_as_string" Problem solved! I figured it out by installing FC23 fresh on a new VM, and I noticed it worked there, and it returns an object type matching the timezone location instead of DateTime::TimeZone::Tzfile (for instance, DateTime::TimeZone::America::Los_Angeles). So the DateTime::TimeZone doesn't error out indicating it cannot determine the timezone location. Even though the system knew it was in PDT timezone as the date command demonstrated, that isn't enough for this package. I had to run system-config-date and set the timezone from there to set it to the closest location - in my case, to Los Angeles. I'm actually surprised more people haven't run into this issue. -Don ------------------------------------------------------------------------ *From:* Don Beusee *Sent:* Tuesday, August 30, 2016 4:57PM *To:* Support-bugzilla *Subject:* Re: Installing recent versions of bugzilla giving error Can't locate object method "offset_as_string" Emmanuel , I have another system, running Fedora 20 x86, and the script works there. This system has an earlier version of DateTime::TimeZone. I modified the simple script to confirm the version of the DateTime::TimeZone package that is actually loaded: #!/usr/bin/perl use DateTime::TimeZone; print "version=" . $DateTime::TimeZone::VERSION . "\n"; my $ltz = DateTime::TimeZone->new(name => 'local'); print "tz offset=" . $ltz->offset_as_string(-25200) . "\n"; When I run this on the Fedora 20 x86 system, I get: [root@pp10-vm ~]# perl test.pl version=1.76 tz offset=-0700 [root@pp10-vm ~]# When I run it on the fedora 23 x64 system, I get: [root@pp10 bugzilla-5.1.1]# perl test.pl version=2.01 Can't locate object method "offset_as_string" via package "DateTime::TimeZone::Tzfile" at test.pl line 5. [root@pp10 bugzilla-5.1.1]# I just added more code to display all the loaded package versions. Can you run the script below and send all the output back to me? #!/usr/bin/perl #BEGIN { #@INC=( # #'/usr/local/lib64/perl5'. # #'/usr/local/share/perl5', # '/usr/lib64/perl5/vendor_perl', # '/usr/share/perl5/vendor_perl', # '/usr/lib64/perl5', # '/usr/share/perl5', # #'.' # ); #} use DateTime::TimeZone; print "DateTime::TimeZone::VERSION=" . $DateTime::TimeZone::VERSION . "\n"; my $ltz = DateTime::TimeZone->new(name => 'local'); #print join $/, keys %INC; foreach my $pp (keys %INC) { my $p=$pp; $p =~ s,/,::,g; $p =~ s,.pm$,,; my $v=$p->VERSION; printf "%-70s %s\n", $INC{$pp}, $v; } print "\n$ltz\n"; print "tz offset=" . $ltz->offset_as_string(-25200) . "\n"; On my system, this script produces this output: [root@pp10 bugzilla-5.1.1]# perl test.pl DateTime::TimeZone::VERSION=2.01 /usr/share/perl5/File/Find.pm 1.29 /usr/lib64/perl5/vendor_perl/Sub/Name.pm 0.14 /usr/local/lib64/perl5/Scalar/Util.pm 1.45 /usr/lib64/perl5/vendor_perl/Params/Validate.pm 1.24 /usr/share/perl5/vars.pm 1.03 /usr/share/perl5/vendor_perl/DateTime/TimeZone/Tzfile.pm 0.010 /usr/share/perl5/vendor_perl/Module/Runtime.pm 0.014 /usr/lib64/perl5/vendor_perl/Params/Validate/XS.pm 1.24 /usr/lib64/perl5/Fcntl.pm 1.13 /usr/lib64/perl5/IO/File.pm 1.16 /usr/share/perl5/vendor_perl/DateTime/TimeZone/Local/Unix.pm 2.01 /usr/share/perl5/vendor_perl/DateTime/TimeZone/Floating.pm 2.01 /usr/lib64/perl5/vendor_perl/Params/Validate/Constants.pm 1.24 /usr/share/perl5/vendor_perl/Carp.pm 1.38 /usr/share/perl5/XSLoader.pm 0.22 /usr/share/perl5/vendor_perl/DateTime/TimeZone/OlsonDB/Change.pm 2.01 /usr/share/perl5/vendor_perl/Try/Tiny.pm 0.22 /usr/lib64/perl5/vendor_perl/File/Spec.pm 3.62 /usr/share/perl5/vendor_perl/Module/Implementation.pm 0.09 /usr/lib64/perl5/vendor_perl/Params/Classify.pm 0.013 /usr/lib64/perl5/vendor_perl/File/Spec/Unix.pm 3.62 /usr/share/perl5/vendor_perl/Exporter.pm 5.72 /usr/share/perl5/vendor_perl/constant.pm 1.33 /usr/lib64/perl5/IO/Seekable.pm 1.1 /usr/lib64/perl5/Config.pm 5.022002 /usr/lib64/perl5/IO/Handle.pm 1.35 /usr/share/perl5/warnings.pm 1.34 /usr/share/perl5/File/Basename.pm 2.85 /usr/share/perl5/File/Compare.pm 1.1006 /usr/lib64/perl5/IO.pm 1.35_01 /usr/share/perl5/Symbol.pm 1.07 /usr/share/perl5/vendor_perl/DateTime/TimeZone/Catalog.pm 2.01 /usr/share/perl5/SelectSaver.pm 1.02 /usr/lib64/perl5/vendor_perl/Cwd.pm 3.62 /usr/share/perl5/vendor_perl/DateTime/TimeZone/Local.pm 2.01 /usr/share/perl5/vendor_perl/DateTime/TimeZone/SystemV.pm 0.009 /usr/share/perl5/vendor_perl/DateTime/TimeZone/UTC.pm 2.01 /usr/share/perl5/vendor_perl/parent.pm 0.234 /usr/share/perl5/vendor_perl/DateTime/TimeZone/OffsetOnly.pm 2.01 /usr/share/perl5/vendor_perl/Class/Singleton.pm 1.5 /usr/share/perl5/vendor_perl/Date/ISO8601.pm 0.004 /usr/share/perl5/strict.pm 1.09 /usr/share/perl5/vendor_perl/DateTime/TimeZone.pm 2.01 /usr/share/perl5/integer.pm 1.01 /usr/share/perl5/warnings/register.pm 1.04 /usr/local/lib64/perl5/List/Util.pm 1.45 DateTime::TimeZone::Tzfile=HASH(0x1b041b8) Can't locate object method "offset_as_string" via package "DateTime::TimeZone::Tzfile" at test.pl line 25. [root@pp10 bugzilla-5.1.1]# Thanks, -Don ------------------------------------------------------------------------ *From:* Emmanuel Seyman *Sent:* Tuesday, August 30, 2016 4:46AM *To:* Support-bugzilla *Subject:* Re: Installing recent versions of bugzilla giving error Can't locate object method "offset_as_string" * Don Beusee [30/08/2016 04:12] : Show quoted text
> This is on a Fedora 2.3 system with the packages
Fedora 2? Fedora 3? Fedora 23? Show quoted text
> This small test program demonstrates the error: > > use DateTime::TimeZone; > my $ltz = DateTime::TimeZone->new(name => 'local'); > print $ltz->offset_as_string(-25200) . "\n";
This works fine on my system (Fedora 24, perl-DateTime-TimeZone-2.01-1). I suspect something is wonky with your timezone. What does the 'date' command return? Emmanuel Show quoted text
_______________________________________________ support-bugzilla mailing list support-bugzilla@lists.mozilla.org https://lists.mozilla.org/listinfo/support-bugzilla PLEASE putsupport-bugzilla@lists.mozilla.org in the To: field when you reply.

Message body is not shown because it is too large.

On Fri Sep 02 03:51:03 2016, don@beusee.com wrote: Show quoted text
> #!/usr/bin/perl > #BEGIN { > #@INC=( > # #'/usr/local/lib64/perl5'. > # #'/usr/local/share/perl5', > # '/usr/lib64/perl5/vendor_perl', > # '/usr/share/perl5/vendor_perl', > # '/usr/lib64/perl5', > # '/usr/share/perl5', > # #'.' > # ); > #} > use DateTime::TimeZone; > print "DateTime::TimeZone::VERSION=" . $DateTime::TimeZone::VERSION . > "\n"; > my $ltz = DateTime::TimeZone->new(name => 'local'); > #print join $/, keys %INC; > foreach my $pp (keys %INC) { > my $p=$pp; > $p =~ s,/,::,g; > $p =~ s,.pm$,,; > my $v=$p->VERSION; > printf "%-70s %s\n", $INC{$pp}, $v; > } > print "\n$ltz\n"; > print "tz offset=" . $ltz->offset_as_string(-25200) . "\n"; > > On my system, this script produces this output: > > [root@pp10 bugzilla-5.1.1]# perl test.pl > DateTime::TimeZone::VERSION=2.01 > /usr/share/perl5/File/Find.pm 1.29 > /usr/lib64/perl5/vendor_perl/Sub/Name.pm 0.14 > /usr/local/lib64/perl5/Scalar/Util.pm 1.45 > /usr/lib64/perl5/vendor_perl/Params/Validate.pm 1.24 > /usr/share/perl5/vars.pm 1.03 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Tzfile.pm 0.010 > /usr/share/perl5/vendor_perl/Module/Runtime.pm 0.014 > /usr/lib64/perl5/vendor_perl/Params/Validate/XS.pm 1.24 > /usr/lib64/perl5/Fcntl.pm 1.13 > /usr/lib64/perl5/IO/File.pm 1.16 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Local/Unix.pm 2.01 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Floating.pm 2.01 > /usr/lib64/perl5/vendor_perl/Params/Validate/Constants.pm 1.24 > /usr/share/perl5/vendor_perl/Carp.pm 1.38 > /usr/share/perl5/XSLoader.pm 0.22 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/OlsonDB/Change.pm 2.01 > /usr/share/perl5/vendor_perl/Try/Tiny.pm 0.22 > /usr/lib64/perl5/vendor_perl/File/Spec.pm 3.62 > /usr/share/perl5/vendor_perl/Module/Implementation.pm 0.09 > /usr/lib64/perl5/vendor_perl/Params/Classify.pm 0.013 > /usr/lib64/perl5/vendor_perl/File/Spec/Unix.pm 3.62 > /usr/share/perl5/vendor_perl/Exporter.pm 5.72 > /usr/share/perl5/vendor_perl/constant.pm 1.33 > /usr/lib64/perl5/IO/Seekable.pm 1.1 > /usr/lib64/perl5/Config.pm 5.022002 > /usr/lib64/perl5/IO/Handle.pm 1.35 > /usr/share/perl5/warnings.pm 1.34 > /usr/share/perl5/File/Basename.pm 2.85 > /usr/share/perl5/File/Compare.pm 1.1006 > /usr/lib64/perl5/IO.pm 1.35_01 > /usr/share/perl5/Symbol.pm 1.07 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Catalog.pm 2.01 > /usr/share/perl5/SelectSaver.pm 1.02 > /usr/lib64/perl5/vendor_perl/Cwd.pm 3.62 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Local.pm 2.01 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/SystemV.pm 0.009 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/UTC.pm 2.01 > /usr/share/perl5/vendor_perl/parent.pm 0.234 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/OffsetOnly.pm 2.01 > /usr/share/perl5/vendor_perl/Class/Singleton.pm 1.5 > /usr/share/perl5/vendor_perl/Date/ISO8601.pm 0.004 > /usr/share/perl5/strict.pm 1.09 > /usr/share/perl5/vendor_perl/DateTime/TimeZone.pm 2.01 > /usr/share/perl5/integer.pm 1.01 > /usr/share/perl5/warnings/register.pm 1.04 > /usr/local/lib64/perl5/List/Util.pm 1.45 > > DateTime::TimeZone::Tzfile=HASH(0x1b041b8) > Can't locate object method "offset_as_string" via package > "DateTime::TimeZone::Tzfile" at test.pl line 25.
I am _extremely_ confused. DateTime::TimeZone::TzFile is its own CPAN distribution, and is not part of DateTime::TimeZone. When you call DateTime::TimeZone->new( name => 'local' ) it is 100% impossible that you would get a DateTime::TimeZone::TzFile object back. When you ask for the local time zone from DT::TZ (my distro, against which you reported this bug), it either returns a time zone object from the DT::TZ distro (something like DateTime::TimeZone::America::Los_Angeles) or throws an exception. It has _never_ returned a DT::TZ::TzFile object. See https://metacpan.org/pod/DateTime::TimeZone#The-local-time-zone for more details on how this works. The error you're seeing makes sense since the DateTime::TimeZone::TzFile class (not provided by my distro) doesn't provide an offset_as_string method. Actually, DT::TZ only provides this as a class method anyway. It's not really meaningful to call this on an object, though it would work, I guess. So I'm not sure what's going on. One possibility is that the code above is not actually the code that you ran, _or_ you somehow have a weirdly patched version of DateTime::TimeZone on your system. Either way, I don't think this is a bug in this distro, nor is it really a bug in DT::TZ::TzFile, AFAICT. Cheers, -dave
Subject: Re: [rt.cpan.org #117431] Fwd: DateTime::TimeZone giving error Can't locate object method "offset_as_string"
Date: Fri, 2 Sep 2016 09:55:18 -0700
To: bug-DateTime-TimeZone [...] rt.cpan.org
From: Don Beusee <don [...] beusee.com>
It IS the code I ran, and no, the packages have NOT been modified! It did not error out on the new() call and I did in fact get the Tzfile object until I configured the timezone location. After I configured my system for location Los Angeles, I did indeed get a DateTime::TimeZone::America::Los_Angeles object, but before that I got a DateTime::TimeZone::Tzfile object! If you give me some debug code, I'll get my system back into the state where the location is not configured, and I'll run it for you and return the output to you. -Don On Sep 2, 2016 6:57 AM, "Dave Rolsky via RT" < bug-DateTime-TimeZone@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=117431 > > > On Fri Sep 02 03:51:03 2016, don@beusee.com wrote: >
> > #!/usr/bin/perl > > #BEGIN { > > #@INC=( > > # #'/usr/local/lib64/perl5'. > > # #'/usr/local/share/perl5', > > # '/usr/lib64/perl5/vendor_perl', > > # '/usr/share/perl5/vendor_perl', > > # '/usr/lib64/perl5', > > # '/usr/share/perl5', > > # #'.' > > # ); > > #} > > use DateTime::TimeZone; > > print "DateTime::TimeZone::VERSION=" . $DateTime::TimeZone::VERSION . > > "\n"; > > my $ltz = DateTime::TimeZone->new(name => 'local'); > > #print join $/, keys %INC; > > foreach my $pp (keys %INC) { > > my $p=$pp; > > $p =~ s,/,::,g; > > $p =~ s,.pm$,,; > > my $v=$p->VERSION; > > printf "%-70s %s\n", $INC{$pp}, $v; > > } > > print "\n$ltz\n"; > > print "tz offset=" . $ltz->offset_as_string(-25200) . "\n"; > > > > On my system, this script produces this output: > > > > [root@pp10 bugzilla-5.1.1]# perl test.pl > > DateTime::TimeZone::VERSION=2.01 > > /usr/share/perl5/File/Find.pm 1.29 > > /usr/lib64/perl5/vendor_perl/Sub/Name.pm 0.14 > > /usr/local/lib64/perl5/Scalar/Util.pm 1.45 > > /usr/lib64/perl5/vendor_perl/Params/Validate.pm 1.24 > > /usr/share/perl5/vars.pm 1.03 > > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Tzfile.pm 0.010 > > /usr/share/perl5/vendor_perl/Module/Runtime.pm 0.014 > > /usr/lib64/perl5/vendor_perl/Params/Validate/XS.pm 1.24 > > /usr/lib64/perl5/Fcntl.pm 1.13 > > /usr/lib64/perl5/IO/File.pm 1.16 > > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Local/Unix.pm 2.01 > > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Floating.pm 2.01 > > /usr/lib64/perl5/vendor_perl/Params/Validate/Constants.pm 1.24 > > /usr/share/perl5/vendor_perl/Carp.pm 1.38 > > /usr/share/perl5/XSLoader.pm 0.22 > > /usr/share/perl5/vendor_perl/DateTime/TimeZone/OlsonDB/Change.pm 2.01 > > /usr/share/perl5/vendor_perl/Try/Tiny.pm 0.22 > > /usr/lib64/perl5/vendor_perl/File/Spec.pm 3.62 > > /usr/share/perl5/vendor_perl/Module/Implementation.pm 0.09 > > /usr/lib64/perl5/vendor_perl/Params/Classify.pm 0.013 > > /usr/lib64/perl5/vendor_perl/File/Spec/Unix.pm 3.62 > > /usr/share/perl5/vendor_perl/Exporter.pm 5.72 > > /usr/share/perl5/vendor_perl/constant.pm 1.33 > > /usr/lib64/perl5/IO/Seekable.pm 1.1 > > /usr/lib64/perl5/Config.pm 5.022002 > > /usr/lib64/perl5/IO/Handle.pm 1.35 > > /usr/share/perl5/warnings.pm 1.34 > > /usr/share/perl5/File/Basename.pm 2.85 > > /usr/share/perl5/File/Compare.pm 1.1006 > > /usr/lib64/perl5/IO.pm 1.35_01 > > /usr/share/perl5/Symbol.pm 1.07 > > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Catalog.pm 2.01 > > /usr/share/perl5/SelectSaver.pm 1.02 > > /usr/lib64/perl5/vendor_perl/Cwd.pm 3.62 > > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Local.pm 2.01 > > /usr/share/perl5/vendor_perl/DateTime/TimeZone/SystemV.pm 0.009 > > /usr/share/perl5/vendor_perl/DateTime/TimeZone/UTC.pm 2.01 > > /usr/share/perl5/vendor_perl/parent.pm 0.234 > > /usr/share/perl5/vendor_perl/DateTime/TimeZone/OffsetOnly.pm 2.01 > > /usr/share/perl5/vendor_perl/Class/Singleton.pm 1.5 > > /usr/share/perl5/vendor_perl/Date/ISO8601.pm 0.004 > > /usr/share/perl5/strict.pm 1.09 > > /usr/share/perl5/vendor_perl/DateTime/TimeZone.pm 2.01 > > /usr/share/perl5/integer.pm 1.01 > > /usr/share/perl5/warnings/register.pm 1.04 > > /usr/local/lib64/perl5/List/Util.pm 1.45 > > > > DateTime::TimeZone::Tzfile=HASH(0x1b041b8) > > Can't locate object method "offset_as_string" via package > > "DateTime::TimeZone::Tzfile" at test.pl line 25.
> > I am _extremely_ confused. DateTime::TimeZone::TzFile is its own CPAN > distribution, and is not part of DateTime::TimeZone. When you call > DateTime::TimeZone->new( name => 'local' ) it is 100% impossible that you > would get a DateTime::TimeZone::TzFile object back. > > When you ask for the local time zone from DT::TZ (my distro, against which > you > reported this bug), it either returns a time zone object from the DT::TZ > distro (something like DateTime::TimeZone::America::Los_Angeles) or > throws an > exception. It has _never_ returned a DT::TZ::TzFile object. > > See https://metacpan.org/pod/DateTime::TimeZone#The-local-time-zone for > more > details on how this works. > > The error you're seeing makes sense since the DateTime::TimeZone::TzFile > class > (not provided by my distro) doesn't provide an offset_as_string > method. Actually, DT::TZ only provides this as a class method anyway. It's > not > really meaningful to call this on an object, though it would work, I guess. > > So I'm not sure what's going on. One possibility is that the code above is > not > actually the code that you ran, _or_ you somehow have a weirdly patched > version of DateTime::TimeZone on your system. Either way, I don't think > this > is a bug in this distro, nor is it really a bug in DT::TZ::TzFile, AFAICT. > > > Cheers, > > -dave > >
Subject: Re: [rt.cpan.org #117431] Fwd: DateTime::TimeZone giving error Can't locate object method "offset_as_string"
Date: Fri, 2 Sep 2016 12:12:24 -0700
To: bug-DateTime-TimeZone [...] rt.cpan.org
From: Don Beusee <don [...] beusee.com>
I figured out what must have happened. /etc/localtime was a copy of an earlier version of the zoneinfo. I don't know how this originally happened, since I never paid any attention to this file. I did upgrade from Fedora 20 to Fedora 23 some time in the last year. To reproduce the issue, I copied a Fedora 20 file to my Fedora 23 system and now I get a Tzfile object again. Line 17 from DateTime/TimeZone/Local.pm produces the Tzfile object: my $tz = $subclass->$meth(); $subclass->$meth resolves to: DateTime::TimeZone::Local::Unix->FromEtcLocaltimeContent Note that the date command works - it knows it's in PDT and it returns the correct time. -Don ------------------------------------------------------------------------ *From:* Dave Rolsky Via Rt *Sent:* Friday, September 02, 2016 6:57AM *To:* Don *Subject:* [rt.cpan.org #117431] Fwd: DateTime::TimeZone giving error Can't locate object method "offset_as_string" <URL: https://rt.cpan.org/Ticket/Display.html?id=117431 > On Fri Sep 02 03:51:03 2016, don@beusee.com wrote: Show quoted text
> #!/usr/bin/perl > #BEGIN { > #@INC=( > # #'/usr/local/lib64/perl5'. > # #'/usr/local/share/perl5', > # '/usr/lib64/perl5/vendor_perl', > # '/usr/share/perl5/vendor_perl', > # '/usr/lib64/perl5', > # '/usr/share/perl5', > # #'.' > # ); > #} > use DateTime::TimeZone; > print "DateTime::TimeZone::VERSION=" . $DateTime::TimeZone::VERSION . > "\n"; > my $ltz = DateTime::TimeZone->new(name => 'local'); > #print join $/, keys %INC; > foreach my $pp (keys %INC) { > my $p=$pp; > $p =~ s,/,::,g; > $p =~ s,.pm$,,; > my $v=$p->VERSION; > printf "%-70s %s\n", $INC{$pp}, $v; > } > print "\n$ltz\n"; > print "tz offset=" . $ltz->offset_as_string(-25200) . "\n"; > > On my system, this script produces this output: > > [root@pp10 bugzilla-5.1.1]# perl test.pl > DateTime::TimeZone::VERSION=2.01 > /usr/share/perl5/File/Find.pm 1.29 > /usr/lib64/perl5/vendor_perl/Sub/Name.pm 0.14 > /usr/local/lib64/perl5/Scalar/Util.pm 1.45 > /usr/lib64/perl5/vendor_perl/Params/Validate.pm 1.24 > /usr/share/perl5/vars.pm 1.03 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Tzfile.pm 0.010 > /usr/share/perl5/vendor_perl/Module/Runtime.pm 0.014 > /usr/lib64/perl5/vendor_perl/Params/Validate/XS.pm 1.24 > /usr/lib64/perl5/Fcntl.pm 1.13 > /usr/lib64/perl5/IO/File.pm 1.16 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Local/Unix.pm 2.01 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Floating.pm 2.01 > /usr/lib64/perl5/vendor_perl/Params/Validate/Constants.pm 1.24 > /usr/share/perl5/vendor_perl/Carp.pm 1.38 > /usr/share/perl5/XSLoader.pm 0.22 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/OlsonDB/Change.pm 2.01 > /usr/share/perl5/vendor_perl/Try/Tiny.pm 0.22 > /usr/lib64/perl5/vendor_perl/File/Spec.pm 3.62 > /usr/share/perl5/vendor_perl/Module/Implementation.pm 0.09 > /usr/lib64/perl5/vendor_perl/Params/Classify.pm 0.013 > /usr/lib64/perl5/vendor_perl/File/Spec/Unix.pm 3.62 > /usr/share/perl5/vendor_perl/Exporter.pm 5.72 > /usr/share/perl5/vendor_perl/constant.pm 1.33 > /usr/lib64/perl5/IO/Seekable.pm 1.1 > /usr/lib64/perl5/Config.pm 5.022002 > /usr/lib64/perl5/IO/Handle.pm 1.35 > /usr/share/perl5/warnings.pm 1.34 > /usr/share/perl5/File/Basename.pm 2.85 > /usr/share/perl5/File/Compare.pm 1.1006 > /usr/lib64/perl5/IO.pm 1.35_01 > /usr/share/perl5/Symbol.pm 1.07 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Catalog.pm 2.01 > /usr/share/perl5/SelectSaver.pm 1.02 > /usr/lib64/perl5/vendor_perl/Cwd.pm 3.62 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/Local.pm 2.01 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/SystemV.pm 0.009 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/UTC.pm 2.01 > /usr/share/perl5/vendor_perl/parent.pm 0.234 > /usr/share/perl5/vendor_perl/DateTime/TimeZone/OffsetOnly.pm 2.01 > /usr/share/perl5/vendor_perl/Class/Singleton.pm 1.5 > /usr/share/perl5/vendor_perl/Date/ISO8601.pm 0.004 > /usr/share/perl5/strict.pm 1.09 > /usr/share/perl5/vendor_perl/DateTime/TimeZone.pm 2.01 > /usr/share/perl5/integer.pm 1.01 > /usr/share/perl5/warnings/register.pm 1.04 > /usr/local/lib64/perl5/List/Util.pm 1.45 > > DateTime::TimeZone::Tzfile=HASH(0x1b041b8) > Can't locate object method "offset_as_string" via package > "DateTime::TimeZone::Tzfile" at test.pl line 25.
I am _extremely_ confused. DateTime::TimeZone::TzFile is its own CPAN distribution, and is not part of DateTime::TimeZone. When you call DateTime::TimeZone->new( name => 'local' ) it is 100% impossible that you would get a DateTime::TimeZone::TzFile object back. When you ask for the local time zone from DT::TZ (my distro, against which you reported this bug), it either returns a time zone object from the DT::TZ distro (something like DateTime::TimeZone::America::Los_Angeles) or throws an exception. It has _never_ returned a DT::TZ::TzFile object. See https://metacpan.org/pod/DateTime::TimeZone#The-local-time-zone for more details on how this works. The error you're seeing makes sense since the DateTime::TimeZone::TzFile class (not provided by my distro) doesn't provide an offset_as_string method. Actually, DT::TZ only provides this as a class method anyway. It's not really meaningful to call this on an object, though it would work, I guess. So I'm not sure what's going on. One possibility is that the code above is not actually the code that you ran, _or_ you somehow have a weirdly patched version of DateTime::TimeZone on your system. Either way, I don't think this is a bug in this distro, nor is it really a bug in DT::TZ::TzFile, AFAICT. Cheers, -dave
On Fri Sep 02 15:07:26 2016, don@beusee.com wrote: Show quoted text
> I figured out what must have happened. /etc/localtime was a copy of > an > earlier version of the zoneinfo. I don't know how this originally > happened, since I never paid any attention to this file. I did > upgrade > from Fedora 20 to Fedora 23 some time in the last year. > > To reproduce the issue, I copied a Fedora 20 file to my Fedora 23 > system > and now I get a Tzfile object again. > > Line 17 from DateTime/TimeZone/Local.pm produces the Tzfile object: > my $tz = $subclass->$meth(); > > $subclass->$meth resolves to: > DateTime::TimeZone::Local::Unix->FromEtcLocaltimeContent
Which cannot return a DT::TZ::TzFile object. It you look at that method, you'll see that it ultimately calls back to DateTime::TimeZone->new with a time zone name (that isn't "local"). The only way I can see this happening is if you had a locally patched version of the DateTime-TimeZone distro or if something was monkey-patching it in the process where this happened. Maybe Red Hat did this? They've done some weird stuff with their Perl in the past, though this would be a new level of weirdness. Somewhat unrelatedly, whatever software is calling ->offset_as_seconds on a time zone _object_ should be fixed. This method should be called as a class method on DateTime::TimeZone.
Subject: Re: [rt.cpan.org #117431] Fwd: DateTime::TimeZone giving error Can't locate object method "offset_as_string"
Date: Sat, 3 Sep 2016 14:14:33 -0700
To: bug-DateTime-TimeZone [...] rt.cpan.org
From: Don Beusee <don [...] beusee.com>
I debugged this further, and found out you are right! Unix.pm is modified in the Fedora Project. I don't know why they modified it, because your package from CPAN works correctly. I get the correct error with the FC20 localtime file and I get the correct result with the FC23 localtime file. I filed this Fedora bug just now: https://bugzilla.redhat.com/show_bug.cgi?id=1372923 I agree with you regarding offset_as_seconds(). -Don ------------------------------------------------------------------------ *From:* Dave Rolsky Via Rt *Sent:* Saturday, September 03, 2016 7:04AM *To:* Don *Subject:* [rt.cpan.org #117431] Fwd: DateTime::TimeZone giving error Can't locate object method "offset_as_string" <URL: https://rt.cpan.org/Ticket/Display.html?id=117431 > On Fri Sep 02 15:07:26 2016, don@beusee.com wrote: Show quoted text
> I figured out what must have happened. /etc/localtime was a copy of > an > earlier version of the zoneinfo. I don't know how this originally > happened, since I never paid any attention to this file. I did > upgrade > from Fedora 20 to Fedora 23 some time in the last year. > > To reproduce the issue, I copied a Fedora 20 file to my Fedora 23 > system > and now I get a Tzfile object again. > > Line 17 from DateTime/TimeZone/Local.pm produces the Tzfile object: > my $tz = $subclass->$meth(); > > $subclass->$meth resolves to: > DateTime::TimeZone::Local::Unix->FromEtcLocaltimeContent
Which cannot return a DT::TZ::TzFile object. It you look at that method, you'll see that it ultimately calls back to DateTime::TimeZone->new with a time zone name (that isn't "local"). The only way I can see this happening is if you had a locally patched version of the DateTime-TimeZone distro or if something was monkey-patching it in the process where this happened. Maybe Red Hat did this? They've done some weird stuff with their Perl in the past, though this would be a new level of weirdness. Somewhat unrelatedly, whatever software is calling ->offset_as_seconds on a time zone _object_ should be fixed. This method should be called as a class method on DateTime::TimeZone.