package PublicInbox::Admin;
use v5.12;
use parent qw(Exporter);
-our @EXPORT_OK = qw(setup_signals);
+our @EXPORT_OK = qw(setup_signals fmt_localtime);
use PublicInbox::Config;
use PublicInbox::Inbox;
use PublicInbox::Spawn qw(run_qx);
}
}
+sub fmt_localtime ($) {
+ require POSIX;
+ my @lt = localtime $_[0];
+ my (undef, $M, $H, $d, $m, $Y) = @lt;
+ sprintf('%u-%02u-%02u % 2u:%02u ', $Y + 1900, $m + 1, $d, $H, $M)
+ .POSIX::strftime('%z', @lt);
+}
+
1;
use Carp qw(croak carp);
use Scalar::Util qw(blessed);
use Sys::Hostname qw(hostname);
-use POSIX qw(strftime);
use File::Glob qw(bsd_glob GLOB_NOSORT);
use PublicInbox::MultiGit;
use PublicInbox::Search;
use PublicInbox::Eml;
use PublicInbox::DS qw(now add_timer);
use DBI qw(:sql_types); # SQL_BLOB
+use PublicInbox::Admin qw(fmt_localtime);
sub new {
my (undef, $dir, $opt) = @_;
return $locked if $locked eq $cur;
}
my ($pid, $time, $euid, $ident) = split(/-/, $cur, 4);
- my $t = strftime('%Y-%m-%d %k:%M %z', localtime($time));
+ my $t = fmt_localtime($time);
local $self->{current_info} = 'eidxq';
if ($euid == $> && $ident eq host_ident) {
kill(0, $pid) and warn <<EOM and return;
sub ts2str ($) { strftime('%Y%m%d%H%M%S', gmtime($_[0])) };
# human-friendly format
-sub fmt_ts ($) { strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
+sub fmt_ts ($) {
+ # strftime %k is not portable and leading zeros in %H slow me down
+ my (undef, $M, $H, $d, $m, $Y) = gmtime $_[0];
+ sprintf '%u-%02u-%02u % 2u:%02u', $Y + 1900, $m + 1, $d, $H, $M;
+}
sub utf8_maybe ($) {
utf8::decode($_[0]);
use PublicInbox::OnDestroy;
use PublicInbox::SHA qw(sha256_hex sha_all);
use POSIX qw(strftime);
+use PublicInbox::Admin qw(fmt_localtime);
use autodie qw(chdir chmod close open pipe readlink
seek symlink sysopen sysseek truncate unlink);
# set by clone_v2_prep/-I/--exclude
my $mis = delete $self->{chg}->{fp_mismatch};
if ($mis) {
- my $t = (stat($ft))[9];
- $t = strftime('%F %k:%M:%S %z', localtime($t));
+ my $t = fmt_localtime((stat($ft))[9]);
warn <<EOM;
W: Fingerprints for the following repositories do not match
W: $mf_url @ $t:
$rft = $diff;
}
$lr -= ($rft || (48 * 60 * 60));
+ require PublicInbox::Admin;
$lei->qerr("# $uri limiting to ".
- strftime('%Y-%m-%d %k:%M %z', localtime($lr)). ' and newer');
+ PublicInbox::Admin::fmt_localtime($lr).' and newer');
# this should really be rt: (received-time), but no stable
# public-inbox releases support it, yet.
my $dt = 'dt:'.strftime('%Y%m%d%H%M%S', gmtime($lr)).'..';
use v5.10.1;
use parent qw(Exporter);
use Fcntl qw(SEEK_SET O_RDONLY O_NONBLOCK);
-use POSIX qw(strftime);
use HTTP::Date qw(time2str);
use HTTP::Status qw(status_message);
use Errno qw(EACCES ENOTDIR ENOENT);
use URI::Escape qw(uri_escape_utf8);
use PublicInbox::GzipFilter qw(gzf_maybe);
-use PublicInbox::Hval qw(ascii_html);
+use PublicInbox::Hval qw(ascii_html fmt_ts);
use Plack::MIME;
our @EXPORT_OK = qw(@NO_CACHE r path_info_raw);
$pad = 1 if $pad <= 0;
$entry = qq(\n<a\nhref="$href">$name</a>) .
(' ' x $pad) .
- strftime('%Y-%m-%d %k:%M', gmtime($mtime)) .
+ fmt_ts($mtime) .
sprintf('% 8s', $hsize);
}
($old->[0] != $cur->[0]) ||
($old->[1] != $cur->[1]))) {
for ($cur, $old) {
- $_->[2] = strftime('%Y-%m-%d %k:%M:%S', gmtime($_->[0]))
+ $_->[2] = strftime('%F %T', gmtime($_->[0]))
}
is_deeply($cur, $old, "$func $oid");
diag('got: ', explain($cur));