Reputation: 97
I have some code that I'm running with Perl 5.20 on Debian 8.1. But I'm getting a warning and an error in the following line:
Date::Manip::DM6::Date_Init("TZ=+0430");
Warning:
WARNING: the TZ Date::Manip config variable is deprecated
and will be removed in March 2016. Please use
the SetDate or ForceDate config variables instead.
Error:
ERROR: [config_var] invalid zone in SetDate:
at /usr/local/share/perl/5.20.2/Date/Manip/TZ.pm line 1768.
Date::Manip::TZ::_config_var_setdate(Date::Manip::TZ=HASH(0x3a11d80), "now,+0430", 0) called at /usr/local/share/perl/5.20.2/Date/Manip/TZ.pm line 1641
Date::Manip::TZ::_config_var_tz(Date::Manip::TZ=HASH(0x3a11d80), "tz", "+0430") called at /usr/local/share/perl/5.20.2/Date/Manip/TZ_Base.pm line 41
Date::Manip::TZ_Base::_config_var(Date::Manip::TZ=HASH(0x3a11d80), "TZ", "+0430") called at /usr/local/share/perl/5.20.2/Date/Manip/Obj.pm line 250
Date::Manip::Obj::config(Date::Manip::Date=HASH(0x3a119f0), "TZ", "+0430") called at /usr/local/share/perl/5.20.2/Date/Manip/DM6.pm line 96
Date::Manip::DM6::Date_Init("TZ=+0430") called at adsl.pl line 75
How can I fix this?
Upvotes: 2
Views: 1326
Reputation: 24073
The deprecation is explained in Date::Manip::Config
:
TZ
This variable is deprecated, but will be supported for several releases. The
SetDate
orForceDate
variables (described next) should be used instead.The following are equivalent:
$date->config("tz","Europe/Rome"); $date->config("setdate","now,Europe/Rome");
As for the warning about "invalid zone," apparently* Date::Manip
requires you to specify offsets in the format +HH:MM:SS
(or -HH:MM:SS
).
To fix both warnings, change line 75 of adsl.pl from this:
Date_Init("TZ=+0430");
to this:
Date_Init("setdate=now,+04:30:00");
* I don't see this documented anywhere, but the warning is triggered by the following code in Date::Manip::TZ
:
return undef if (! exists $$self{'data'}{'Offmod'}{$offset});
This does a hash lookup in %Date::Manip::Zones::Offmod
, which only has keys in the format +HH:MM:SS
(or -HH:MM:SS
).
Upvotes: 4