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.