Reputation: 25117
When I set my locale
to it_IT.UTF-8
(export LC_ALL=it_IT.UTF-8) and run this script
#!/usr/bin/env perl
use warnings;
use 5.012;
use POSIX qw(strftime);
say strftime "%A %B %e %H:%M:%S %Y", localtime;
I get this output:
martedì marzo 15 08:50:07 2011
but reading this (from 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 .
why does my locale-setting have an influence on the strftime-output without the use of the locale
pragma?
Upvotes: 2
Views: 621
Reputation: 164829
POSIX::strftime
is a thin wrapper around the real strftime
C function call in time.h
which uses the current locale. Perl doesn't go through the effort to make it conform.
DateTime has a strftime equivalent implemented in Perl that will conform to Perl's locale pragma.
Upvotes: 5