使用区域设置 - 问题

时间:2011-03-15 07:58:25

标签: perl locale pragma

当我将locale设置为it_IT.UTF-8(导出LC_ALL = it_IT.UTF-8)并运行此脚本时

#!/usr/bin/env perl
use warnings;
use 5.012;
use POSIX qw(strftime);

say strftime "%A %B %e %H:%M:%S %Y", localtime;

我得到了这个输出:

martedì marzo 15 08:50:07 2011

但阅读此内容(来自The-use-locale-pragma):

By default, Perl ignores the current locale. The use locale pragma tells Perl to use the current locale for some operations: ... The POSIX date formatting function (strftime()) uses LC_TIME .

为什么我的语言环境设置会对strftime-output产生影响而不使用locale pragma?

1 个答案:

答案 0 :(得分:5)

POSIX::strftimestrftime中使用当前区域设置的真实time.h C函数调用的瘦包装器。 Perl没有通过努力使其符合。

在Perl中实现的

DateTime has a strftime equivalent符合Perl的语言环境编译指示。