in reply to Localized weekday names

This works for me. You'll need a recent Time::Piece.

#!/usr/bin/env perl use strict; use warnings; use Time::Piece; use POSIX; my @days = Time::Piece->day_list; print "Days are @days\n"; setlocale( LC_ALL, 'fr_FR' ); Time::Piece->use_locale (); @days = Time::Piece->day_list; print "Days are @days\n";
$ perl days.pl Days are Sun Mon Tue Wed Thu Fri Sat Days are dim. lun. mar. mer. jeu. ven. sam.

Replies are listed 'Best First'.
Re^2: Localized weekday names
by Sec (Monk) on Nov 03, 2017 at 15:42 UTC
    I suspect I have some different version of Time::Piece than what you have:
    mcp:~>perl days.pl Can't locate object method "use_locale" via package "Time::Piece" at d +ays.pl line 10.
    and if I remove the "use_locale" line, I get this interesting result:
    Days are Sun Mon Tue Wed Thu Fri Sat Days are Time::Piece
    I must admit, I have no clue why the second call to Time::Piece does not work anymore.

    Versions are:

    p5-Time-Piece-1.23_1 Time::Piece - Object Oriented time obje +cts This is perl 5, version 24, subversion 3 (v5.24.3) built for amd64-fre +ebsd-thread-multi
    Last, but not least, Time::Piece apparently does not care for the locale by default:
    mcp:~>LC_TIME=de_DE.UTF-8 perl -MTime::Piece -le 'print join",",Time:: +Piece->day_list' Sun,Mon,Tue,Wed,Thu,Fri,Sat
      p5-Time-Piece-1.23_1

      Time::Piece 1.23 is over 4 years old. That really doesn't count as "recent" so no, you would need to upgrade it to take advantage of the new features (and bug fixes and stability improvements and ...). My script was tested against version 1.31_04 which is more modern and the current version is 1.3202 from about 6 weeks ago.

      Last, but not least, Time::Piece apparently does not care for the locale by default

      This is precisely why the newer versions have use_locale :-)