about summary refs log tree commit homepage
path: root/t/msgtime.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-12-01 22:04:25 +0000
committerEric Wong <e@80x24.org>2019-12-12 03:51:45 +0000
commit74fd81670fcc9eaec15a009995e52f9aeefa1494 (patch)
treeb26e473c8ec8b91181a6d8677183234edb1c2f72 /t/msgtime.t
parent56643bfddba2f7bca60955e5c48435fe58cc8e1c (diff)
downloadpublic-inbox-74fd81670fcc9eaec15a009995e52f9aeefa1494.tar.gz
Wacky dates show up in lore for valid messages.  Lets ignore
them and let future generations deal with Y10K and time-travel
problems.
Diffstat (limited to 't/msgtime.t')
-rw-r--r--t/msgtime.t14
1 files changed, 12 insertions, 2 deletions
diff --git a/t/msgtime.t b/t/msgtime.t
index 1452dc97..98cf66e6 100644
--- a/t/msgtime.t
+++ b/t/msgtime.t
@@ -5,7 +5,7 @@ use warnings;
 use Test::More;
 use PublicInbox::MIME;
 use PublicInbox::MsgTime;
-
+our $received_date = 'Mon, 22 Jan 2007 13:16:24 -0500';
 sub datestamp ($) {
         my ($date) = @_;
         local $SIG{__WARN__} = sub {};  # Suppress warnings
@@ -17,7 +17,11 @@ sub datestamp ($) {
                         Subject => 'this is a subject',
                         'Message-ID' => '<a@example.com>',
                         Date => $date,
-                        'Received' => '(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S932173AbXAVSQY (ORCPT <rfc822;w@1wt.eu>);\n\tMon, 22 Jan 2007 13:16:24 -0500',
+                        'Received' => <<EOF,
+(majordomo\@vger.kernel.org) by vger.kernel.org via listexpand
+\tid S932173AbXAVSQY (ORCPT <rfc822;w\@1wt.eu>);
+\t$received_date
+EOF
                 ],
                 body => "hello world\n",
             );
@@ -104,4 +108,10 @@ for (qw(UT GMT Z)) {
 }
 is_datestamp('Fri, 02 Oct 1993 00:00:00 EDT', [ 749534400, '-0400']);
 
+# fallback to Received: header if Date: is out-of-range:
+is_datestamp('Fri, 1 Jan 1904 10:12:31 +0100',
+        PublicInbox::MsgTime::str2date_zone($received_date));
+is_datestamp('Fri, 9 Mar 71685 18:45:56 +0000', # Y10K is not my problem :P
+        PublicInbox::MsgTime::str2date_zone($received_date));
+
 done_testing();