将perl从5.16.3升级到5.28.1之后。 DateTime.pm的DefaultLocale函数与5.16.3相比提供不同的输出
locale命令给出以下输出
LANG=de_DE.utf8
LC_CTYPE="de_DE.utf8"
LC_NUMERIC="de_DE.utf8"
LC_TIME="de_DE.utf8"
LC_COLLATE="de_DE.utf8"
LC_MONETARY="de_DE.utf8
LC_MESSAGES="de_DE.utf8"
LC_PAPER="de_DE.utf8"
LC_NAME="de_DE.utf8"
LC_ADDRESS="de_DE.utf8"
LC_TELEPHONE="de_DE.utf8"
LC_MEASUREMENT="de_DE.utf8"
LC_IDENTIFICATION="de_DE.utf8"
LC_ALL=
use warnings;
use strict;
use Carp;
use Data::Dumper;
use Time::Local;
use Params::Validate qw(:all);
use DateTime;
use DateTime::TimeZone;
use POSIX qw(setlocale LC_TIME);
my $locale = setlocale(LC_TIME);
DateTime->DefaultLocale($locale);
print "Time locale :",DateTime::DefaultLocale;
perl 5.28.1提供输出
Time locale :DateTime::Locale::FromData=HASH(xxxxxx)
而perl 5.16.3输出是
Time locale :DateTime::Locale::de_DE=HASH(xxxxx)
答案 0 :(得分:1)
您不应该测试类名。也许您应该测试DateTime->DefaultLocale->code
返回的代码?
use strict;
use warnings;
use feature qw( say );
use DateTime qw( );
DateTime->DefaultLocale('de_DE.utf8');
my $locale = DateTime->DefaultLocale;
say ref($locale);
say $locale->code;
say $locale->day_stand_alone_wide->[0];
输出:
DateTime::Locale::FromData
de-DE
Montag