From: Eric Wong Date: Wed, 11 Oct 2023 07:20:52 +0000 (+0000) Subject: msgtime: simplify msg_timestamp and msg_datestamp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b7cdd9173bd0d74fc181b05c02d90b320d621ae;p=thirdparty%2Fpublic-inbox.git msgtime: simplify msg_timestamp and msg_datestamp We don't need multiple return points nor multiple time_response calls in either function. --- diff --git a/lib/PublicInbox/MsgTime.pm b/lib/PublicInbox/MsgTime.pm index 58b0deae8..bbc9a0070 100644 --- a/lib/PublicInbox/MsgTime.pm +++ b/lib/PublicInbox/MsgTime.pm @@ -157,20 +157,16 @@ sub msg_date_only ($) { # Favors Received header for sorting globally sub msg_timestamp ($;$) { - my ($hdr, $fallback) = @_; # PublicInbox::Eml - my $ret; - $ret = msg_received_at($hdr) and return time_response($ret); - $ret = msg_date_only($hdr) and return time_response($ret); - time_response([ $fallback // time, '+0000' ]); + my ($eml, $fallback) = @_; + time_response(msg_received_at($eml) // msg_date_only($eml) // + [ $fallback // time, '+0000' ]); } # Favors the Date: header for display and sorting within a thread sub msg_datestamp ($;$) { - my ($hdr, $fallback) = @_; # PublicInbox::Eml - my $ret; - $ret = msg_date_only($hdr) and return time_response($ret); - $ret = msg_received_at($hdr) and return time_response($ret); - time_response([ $fallback // time, '+0000' ]); + my ($eml, $fallback) = @_; # PublicInbox::Eml + time_response(msg_date_only($eml) // msg_received_at($eml) // + [ $fallback // time, '+0000' ]); } 1;