From b503e583ede0b35a30aa3f14096c0605e3032439 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 5 Jan 2020 23:23:32 +0000 Subject: 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. --- lib/PublicInbox/View.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/PublicInbox') 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
 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]);
-- 
cgit v1.2.3-24-ge0c7