Skip to content

Commit

Permalink
Merge pull request #442 from dex4er/porting/no_locale
Browse files Browse the repository at this point in the history
POSIX::setlocale fails on system without locales (Android)
  • Loading branch information
miyagawa committed Jan 16, 2014
2 parents b17e171 + 7908e03 commit c5a3896
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/Plack/Middleware/SimpleLogger.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package Plack::Middleware::SimpleLogger;
use strict;
use parent qw(Plack::Middleware);
use Config ();
use Plack::Util::Accessor qw(level);
use POSIX ();
use Scalar::Util ();
Expand Down Expand Up @@ -29,10 +30,15 @@ sub call {
}

sub format_time {
my $old_locale = POSIX::setlocale(&POSIX::LC_ALL);
POSIX::setlocale(&POSIX::LC_ALL, 'C');
my $old_locale;
if ( $Config::config{d_setlocale} ) {
$old_locale = POSIX::setlocale(&POSIX::LC_ALL);
POSIX::setlocale(&POSIX::LC_ALL, 'C');
}
my $out = POSIX::strftime(@_);
POSIX::setlocale(&POSIX::LC_ALL, $old_locale);
if ( $Config::config{d_setlocale} ) {
POSIX::setlocale(&POSIX::LC_ALL, $old_locale);
};
return $out;
}

Expand Down

0 comments on commit c5a3896

Please sign in to comment.