* [PATCH 2/6] view: update POSIX::strftime usage
2020-01-05 23:23 5% [PATCH 0/6] various cleanups around use/require Eric Wong
@ 2020-01-05 23:23 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-01-05 23:23 UTC (permalink / raw)
To: meta
The POSIX module is always loaded, so import `strftime' into the
namespace so we can use it and take advantage of compile-time
arg checking. While we're at it, update and reorder caller
functions to use prototypes, too.
---
lib/PublicInbox/View.pm | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 0d6f3351..e5cc475f 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -16,7 +16,7 @@ use PublicInbox::Address;
use PublicInbox::WwwStream;
use PublicInbox::Reply;
use PublicInbox::ViewDiff qw(flush_diff);
-require POSIX;
+use POSIX qw(strftime);
use Time::Local qw(timegm);
use PublicInbox::SearchMsg qw(subject_normalized);
use constant COLS => 72;
@@ -207,6 +207,9 @@ sub nr_to_s ($$$) {
$nr == 1 ? "$nr $singular" : "$nr $plural";
}
+# human-friendly format
+sub fmt_ts ($) { strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
+
# this is already inside a <pre>
sub index_entry {
my ($smsg, $ctx, $more) = @_;
@@ -925,8 +928,6 @@ sub missing_thread {
PublicInbox::ExtMsg::ext_msg($ctx);
}
-sub fmt_ts { POSIX::strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
-
sub dedupe_subject {
my ($prev_subj, $subj, $val) = @_;
@@ -1158,10 +1159,8 @@ sub dump_topics {
200;
}
-sub ts2str ($) {
- my ($ts) = @_;
- POSIX::strftime('%Y%m%d%H%M%S', gmtime($ts));
-}
+# only for the t= query parameter passed to overview DB
+sub ts2str ($) { strftime('%Y%m%d%H%M%S', gmtime($_[0])) };
sub str2ts ($) {
my ($yyyy, $mon, $dd, $hh, $mm, $ss) = unpack('A4A2A2A2A2A2', $_[0]);
^ permalink raw reply related [relevance 7%]
* [PATCH 0/6] various cleanups around use/require
@ 2020-01-05 23:23 5% Eric Wong
2020-01-05 23:23 7% ` [PATCH 2/6] view: update POSIX::strftime usage Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-01-05 23:23 UTC (permalink / raw)
To: meta
We've accumulated some cruft over the years. Lets get rid of
some of it and find places where we can help Perl figure more
stuff out at compile-time rather than run-time.
Eric Wong (6):
hval: export prurl and add prototype
view: update POSIX::strftime usage
altid: use msgmap at compile time
admin: do not lazy-load Inbox or Config packages
treewide: "require" + "use" cleanup and docs
syscall: modernize away from pre-Perl-5.6 conventions
Makefile.PL | 2 +-
lib/PublicInbox/Admin.pm | 4 ++--
lib/PublicInbox/AltId.pm | 3 +--
lib/PublicInbox/Config.pm | 2 +-
lib/PublicInbox/DS.pm | 5 ++---
lib/PublicInbox/Daemon.pm | 2 +-
lib/PublicInbox/Emergency.pm | 2 +-
lib/PublicInbox/ExtMsg.pm | 5 ++---
lib/PublicInbox/Filter/RubyLang.pm | 1 -
lib/PublicInbox/Git.pm | 2 +-
lib/PublicInbox/GitHTTPBackend.pm | 2 +-
lib/PublicInbox/HTTP.pm | 3 ++-
lib/PublicInbox/HTTPD.pm | 4 ++--
lib/PublicInbox/Hval.pm | 5 +++--
lib/PublicInbox/Import.pm | 2 +-
lib/PublicInbox/Listener.pm | 2 +-
lib/PublicInbox/MboxGz.pm | 1 -
lib/PublicInbox/NNTPD.pm | 2 +-
lib/PublicInbox/NewsWWW.pm | 3 ++-
lib/PublicInbox/Search.pm | 2 --
lib/PublicInbox/SearchIdx.pm | 2 +-
lib/PublicInbox/SearchView.pm | 6 +----
lib/PublicInbox/SolverGit.pm | 2 +-
lib/PublicInbox/Spawn.pm | 1 -
lib/PublicInbox/Syscall.pm | 35 ++++++++++++++----------------
lib/PublicInbox/TLS.pm | 2 --
lib/PublicInbox/Tmpfile.pm | 2 +-
lib/PublicInbox/V2Writable.pm | 2 +-
lib/PublicInbox/View.pm | 17 +++++++--------
lib/PublicInbox/ViewDiff.pm | 2 +-
lib/PublicInbox/WatchMaildir.pm | 2 +-
lib/PublicInbox/WwwAtomStream.pm | 2 +-
lib/PublicInbox/WwwListing.pm | 6 ++---
lib/PublicInbox/WwwStream.pm | 4 ++--
lib/PublicInbox/Xapcmd.pm | 2 +-
script/public-inbox-convert | 2 --
script/public-inbox-edit | 8 +++----
script/public-inbox-init | 4 ++--
script/public-inbox-nntpd | 4 ++--
t/cgi.t | 2 --
t/feed.t | 2 --
41 files changed, 71 insertions(+), 92 deletions(-)
^ permalink raw reply [relevance 5%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-01-05 23:23 5% [PATCH 0/6] various cleanups around use/require Eric Wong
2020-01-05 23:23 7% ` [PATCH 2/6] view: update POSIX::strftime usage Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).