mirror of
https://github.com/webmin/webmin.git
synced 2026-05-04 22:30:33 +01:00
Make sure strftime is always used in C locate
This commit is contained in:
@@ -107,7 +107,10 @@ if ($config{'date_subs'}) {
|
||||
eval "use POSIX";
|
||||
eval "use posix" if ($@);
|
||||
local @tm = localtime(time());
|
||||
return strftime($_[0], @tm);
|
||||
&clear_time_locale();
|
||||
local $rv = strftime($_[0], @tm);
|
||||
&reset_time_locale();
|
||||
return $rv;
|
||||
}
|
||||
else {
|
||||
return $_[0];
|
||||
|
||||
@@ -727,7 +727,10 @@ if ($config{'date_subs'}) {
|
||||
eval "use POSIX";
|
||||
eval "use posix" if ($@);
|
||||
local @tm = localtime(time());
|
||||
return strftime($_[0], @tm);
|
||||
&clear_time_locale();
|
||||
local $rv = strftime($_[0], @tm);
|
||||
&reset_time_locale();
|
||||
return $rv;
|
||||
}
|
||||
else {
|
||||
return $_[0];
|
||||
|
||||
@@ -707,7 +707,10 @@ if ($config{'date_subs'}) {
|
||||
eval "use POSIX";
|
||||
eval "use posix" if ($@);
|
||||
local @tm = localtime(time());
|
||||
return strftime($_[0], @tm);
|
||||
&clear_time_locale();
|
||||
local $rv = strftime($_[0], @tm);
|
||||
&reset_time_locale();
|
||||
return $rv;
|
||||
}
|
||||
else {
|
||||
return $_[0];
|
||||
|
||||
@@ -8400,16 +8400,16 @@ return &get_module_variable('$module_name');
|
||||
sub get_module_variable
|
||||
{
|
||||
my ($v, $wantref) = @_;
|
||||
my $slash = $wantref ? "\\" : "";
|
||||
if (__PACKAGE__ eq 'WebminCore') {
|
||||
my ($vt, $vn) = split('', $v, 2);
|
||||
my $callpkg;
|
||||
for(my $i=0; ($callpkg) = caller($i); $i++) {
|
||||
last if ($callpkg ne __PACKAGE__);
|
||||
}
|
||||
my $slash = $wantref ? "\\" : "";
|
||||
return eval "${slash}${vt}${callpkg}::${vn}";
|
||||
}
|
||||
return eval "$v";
|
||||
return eval "${slash}${v}";
|
||||
}
|
||||
|
||||
# set_module_variable(name, value)
|
||||
@@ -8420,6 +8420,32 @@ my ($v, $value) = @_;
|
||||
# XXX
|
||||
}
|
||||
|
||||
# clear_time_locale()
|
||||
# Temporarily force the locale to C, until reset_time_locale is called
|
||||
sub clear_time_locale
|
||||
{
|
||||
if ($main::clear_time_locale_count == 0) {
|
||||
eval {
|
||||
$main::clear_time_locale_old = POSIX::setlocale(POSIX::LC_TIME);
|
||||
POSIX::setlocale(POSIX::LC_TIME, "C");
|
||||
};
|
||||
}
|
||||
$main::clear_time_locale_count++;
|
||||
}
|
||||
|
||||
# reset_time_locale()
|
||||
# Revert the locale to whatever it was before clear_time_locale was called
|
||||
sub reset_time_locale
|
||||
{
|
||||
if ($main::clear_time_locale_count == 1) {
|
||||
eval {
|
||||
POSIX::setlocale(POSIX::LC_TIME, $main::clear_time_locale_old);
|
||||
$main::clear_time_locale_old = undef;
|
||||
};
|
||||
}
|
||||
$main::clear_time_locale_count--;
|
||||
}
|
||||
|
||||
$done_web_lib_funcs = 1;
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user