From: Eric Wong <e@yhbt.net>
Date: Sun, 5 Jan 2020 23:23:32 +0000 (+0000)
Subject: view: update POSIX::strftime usage
X-Git-Tag: v1.3.0~133
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=b503e583ede0b35a30aa3f14096c0605e3032439;p=public-inbox.git

view: update POSIX::strftime usage

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.
---

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 5acd565a..405da2a9 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;
@@ -208,6 +208,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) = @_;
@@ -926,8 +929,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) = @_;
 
@@ -1159,10 +1160,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]);