From f5d4ad9e1eaafb139e08dcf7dc6ff8ba516ee225 Mon Sep 17 00:00:00 2001 From: IKEDA Soji Date: Wed, 12 Dec 2018 21:43:54 +0900 Subject: [PATCH 1/2] Don't use gettext_strftime() for extension of backup files. --- src/lib/Sympa/Upgrade.pm | 22 ++++++++++------------ src/sbin/sympa_wizard.pl.in | 5 +++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/lib/Sympa/Upgrade.pm b/src/lib/Sympa/Upgrade.pm index 27bcefef3..ad2e2f69b 100644 --- a/src/lib/Sympa/Upgrade.pm +++ b/src/lib/Sympa/Upgrade.pm @@ -32,7 +32,6 @@ use warnings; use Encode qw(); use English qw(-no_match_vars); use MIME::Base64 qw(); -use POSIX qw(); use Time::Local qw(); use Sympa; @@ -934,7 +933,7 @@ sub upgrade { my $fh; my %migrated = (); my @newconf = (); - my $date; + my ($date, $human_date); ## Some sympa.conf parameters were overridden by wwsympa.conf. ## Others prefer sympa.conf. @@ -978,8 +977,9 @@ sub upgrade { ## Set language of new file content $language->push_lang($Conf::Conf{'lang'}); - $date = - $language->gettext_strftime("%d.%b.%Y-%H.%M.%S", localtime time); + $date = time; + $human_date = $language->gettext_strftime('%d %b %Y at %H:%M:%S', + localtime $date); if (-r $wwsympa_conf) { ## load only sympa.conf @@ -1077,7 +1077,7 @@ sub upgrade { . ('#' x 76) . "\n" . '#### ' . $language->gettext("Migration from wwsympa.conf") . "\n" . '#### ' - . $date . "\n" + . $human_date . "\n" . ('#' x 76) . "\n\n"; foreach my $type (qw(duplicate add obsolete unknown)) { @@ -1989,8 +1989,8 @@ sub to_utf8 { next unless $modified; - my $date = POSIX::strftime("%Y.%m.%d-%H.%M.%S", localtime(time)); - unless (rename $file, $file . '@' . $date) { + my $date = time; + unless (rename $file, $file . '.' . $date) { $log->syslog('err', "Cannot rename old template %s", $file); next; } @@ -2013,7 +2013,7 @@ sub to_utf8 { next; } $log->syslog('notice', 'Modified file %s; original file kept as %s', - $file, $file . '@' . $date); + $file, $file . '.' . $date); $total++; } @@ -2099,8 +2099,7 @@ sub fix_colors { $new_conf .= "$line\n"; } # Save previous config file - my $date = - $language->gettext_strftime("%d.%b.%Y-%H.%M.%S", localtime time); + my $date = time; unless (rename($file, "$file.upgrade$date")) { $log->syslog( 'err', @@ -2143,8 +2142,7 @@ sub save_web_tt2 { ); return 0; } - my $date = - $language->gettext_strftime("%d.%b.%Y-%H.%M.%S", localtime time); + my $date = time; unless (rename($dir, "$dir.upgrade$date")) { $log->syslog( 'err', diff --git a/src/sbin/sympa_wizard.pl.in b/src/sbin/sympa_wizard.pl.in index 629ac229d..f31fba8db 100644 --- a/src/sbin/sympa_wizard.pl.in +++ b/src/sbin/sympa_wizard.pl.in @@ -89,7 +89,6 @@ if ($modfail) { ? Sympa::Tools::Text::pad($language->gettext($_[0]), $_[1]) : $language->gettext($_[0]); }; - *gettext_strftime = sub { $language->gettext_strftime(@_) }; my $lang = $ENV{'LANGUAGE'} || $ENV{'LC_ALL'} || $ENV{'LANG'}; $lang =~ s/\..*// if $lang; @@ -400,7 +399,9 @@ sub edit_configuration { } if ($somechange) { - my $date = gettext_strftime("%d.%b.%Y-%H.%M.%S", localtime(time)); + my @time = localtime time; + my $date = sprintf '%d%02d%02d%02d%02d%02d', + $time[5] + 1900, $time[4] + 1, @time[3, 2, 1, 0]; ## Keep old config file unless (rename $sympa_conf, $sympa_conf . '.' . $date) { -- GitLab From 4f80d9d37de5623c2b298a67ea74f061538cc1fa Mon Sep 17 00:00:00 2001 From: IKEDA Soji Date: Wed, 12 Dec 2018 21:45:07 +0900 Subject: [PATCH 2/2] Another redundant use of gettext_strftime(). --- default/web_tt2/viewlogs.tt2 | 6 +++++- src/cgi/wwsympa.fcgi.in | 8 +++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/default/web_tt2/viewlogs.tt2 b/default/web_tt2/viewlogs.tt2 index 2e3237f75..ca597cfd1 100644 --- a/default/web_tt2/viewlogs.tt2 +++ b/default/web_tt2/viewlogs.tt2 @@ -80,7 +80,11 @@ [%# Reset button will be inserted here. ~%] -[%|loc%]Search period: [%END%][%|locdt(date_from_formated)%]%d %b %Y %H:%M:%S[%END%] [%|loc%]to[%END%] [%|locdt(date_to_formated)%]%d %b %Y %H:%M:%S[%END%]
+[%|loc%]Search period: [%END%] + [% date_from_formated | optdesc('unixtime') %] + [%|loc%]to[%END%] + [% date_to_formated | optdesc('unixtime') %] +
[% IF total_results %] [%|loc(list)%]Research was carried out in list %1.[%END%]

diff --git a/src/cgi/wwsympa.fcgi.in b/src/cgi/wwsympa.fcgi.in index e2056dc17..5d0cb88a9 100644 --- a/src/cgi/wwsympa.fcgi.in +++ b/src/cgi/wwsympa.fcgi.in @@ -16196,11 +16196,9 @@ sub do_viewlogs { $param->{'total_results'} = 0; - my @date = $log->get_log_date(); - $param->{'date_from_formated'} = - $language->gettext_strftime("%Y-%m-%d-%H-%M-%S", localtime($date[0])); - $param->{'date_to_formated'} = - $language->gettext_strftime("%Y-%m-%d-%H-%M-%S", localtime($date[1])); + my @dates = $log->get_log_date; + ($param->{'date_from_formated'}, $param->{'date_to_formated'}) = @dates + if @dates; # Display and search parameters preparation. my $select = { -- GitLab