diff options
author | Eric Wong <e@yhbt.net> | 2020-03-20 08:18:13 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-03-22 09:00:23 +0000 |
commit | 8e81d6f0d44198717ae540421a09824d75c9bb6d (patch) | |
tree | 754d15673307a90dcba5aa4cb088f7cbcd2ece49 /lib/PublicInbox/MsgTime.pm | |
parent | c29b2b7ded47def906cf00e3baad65c102304120 (diff) | |
download | public-inbox-8e81d6f0d44198717ae540421a09824d75c9bb6d.tar.gz |
When indexing messages without Date: and/or Received: headers, fall back to using timestamps originally recorded by git in the commit object. This allows git mirrors to preserve the import datestamp and timestamp of a message according to what was fed into git, instead of blindly falling back to the current time.
Diffstat (limited to 'lib/PublicInbox/MsgTime.pm')
-rw-r--r-- | lib/PublicInbox/MsgTime.pm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/PublicInbox/MsgTime.pm b/lib/PublicInbox/MsgTime.pm index 8703d7bc..bd7ef811 100644 --- a/lib/PublicInbox/MsgTime.pm +++ b/lib/PublicInbox/MsgTime.pm @@ -167,21 +167,21 @@ sub msg_date_only ($) { } # Favors Received header for sorting globally -sub msg_timestamp ($) { - my ($hdr) = @_; # Email::MIME::Header +sub msg_timestamp ($;$) { + my ($hdr, $fallback) = @_; # Email::MIME::Header my $ret; $ret = msg_received_at($hdr) and return time_response($ret); $ret = msg_date_only($hdr) and return time_response($ret); - wantarray ? (time, '+0000') : time; + time_response([ $fallback // time, '+0000' ]); } # Favors the Date: header for display and sorting within a thread -sub msg_datestamp ($) { - my ($hdr) = @_; # Email::MIME::Header +sub msg_datestamp ($;$) { + my ($hdr, $fallback) = @_; # Email::MIME::Header my $ret; $ret = msg_date_only($hdr) and return time_response($ret); $ret = msg_received_at($hdr) and return time_response($ret); - wantarray ? (time, '+0000') : time; + time_response([ $fallback // time, '+0000' ]); } 1; |