]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: update POSIX::strftime usage
authorEric Wong <e@yhbt.net>
Sun, 5 Jan 2020 23:23:32 +0000 (23:23 +0000)
committerEric Wong <e@yhbt.net>
Mon, 6 Jan 2020 10:20:45 +0000 (10:20 +0000)
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

index 5acd565a743543ef9db41e4716f1338a4dec71c8..405da2a930a9fe104983cfec75ea20ea45d8bb72 100644 (file)
@@ -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]);