Instantly share code, notes, and snippets.

What would you like to do?
localized strftime in perl
use strict;
use warnings;
use utf8;
use 5.10.0;
use POSIX ();
sub localize_strftime {
my $locale = shift;
my $default = POSIX::setlocale(POSIX::LC_TIME);
POSIX::setlocale(POSIX::LC_TIME, $locale);
my $retval = POSIX::strftime(@_);
POSIX::setlocale(POSIX::LC_TIME, $default);
return $retval;
say+localize_strftime('en_US', '%a, %d %b %Y %T %z', localtime(time));
say+localize_strftime('ja_JP.UTF8', '%a, %d %b %Y %T %z', localtime(time));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment