X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=xt%2Fmsgtime_cmp.t;h=ae9e42152a1afea811ea2daf1f1d513da81e863a;hb=757652fd1ad6843c984610263a2a0b336c974111;hp=469756c61357b3ec5b5373023a9b53f0a48ea2b8;hpb=bad45b4d566afb1dea0404589f0e608b91e7a7a0;p=public-inbox.git
diff --git a/xt/msgtime_cmp.t b/xt/msgtime_cmp.t
index 469756c6..ae9e4215 100644
--- a/xt/msgtime_cmp.t
+++ b/xt/msgtime_cmp.t
@@ -1,15 +1,15 @@
#!perl -w
-# Copyright (C) 2019 all contributors
+# Copyright (C) 2019-2021 all contributors
# License: AGPL-3.0+
use strict;
use Test::More;
use PublicInbox::TestCommon;
-use PublicInbox::MIME;
+use PublicInbox::Eml;
use PublicInbox::Inbox;
use PublicInbox::Git;
use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
use POSIX qw(strftime);
-eval { require Date::Parse } or plan skip_all => "Date::Parse missing for $0";
+require_mods('Date::Parse');
my $git;
my ($inboxdir, $git_dir) = @ENV{qw(GIANT_INBOX_DIR GIANT_GIT_DIR)};
if (defined $inboxdir) {
@@ -48,7 +48,7 @@ sub quiet_is_deeply ($$$$$) {
sub compare {
my ($bref, $oid, $type, $size) = @_;
local $SIG{__WARN__} = sub { diag "$oid: ", @_ };
- my $mime = PublicInbox::MIME->new($$bref);
+ my $mime = PublicInbox::Eml->new($$bref);
my $hdr = $mime->header_obj;
my @cur = msg_datestamp($hdr);
my @old = Old::msg_datestamp($hdr);
@@ -59,11 +59,10 @@ sub compare {
}
my $fh = $git->popen(@cat);
-$git->cat_async_begin;
while (<$fh>) {
my ($oid, $type) = split / /;
next if $type ne 'blob';
- $git->cat_async($oid, *compare);
+ $git->cat_async($oid, \&compare);
}
$git->cat_async_wait;
ok(1);
@@ -82,6 +81,13 @@ sub str2date_zone ($) {
# off is the time zone offset in seconds from GMT
my ($ss,$mm,$hh,$day,$month,$year,$off) = Date::Parse::strptime($date);
+
+ # new behavior which wasn't in the original old version:
+ if ('commit d857e7dc0d816b635a7ead09c3273f8c2d2434be') {
+ # "msgtime: assume +0000 if TZ missing when using Date::Parse"
+ $off //= '+0000';
+ }
+
return undef unless(defined $off);
# Compute the time zone from offset
@@ -109,7 +115,7 @@ sub time_response ($) {
}
sub msg_received_at ($) {
- my ($hdr) = @_; # Email::MIME::Header
+ my ($hdr) = @_; # PublicInbox::Eml
my @recvd = $hdr->header_raw('Received');
my ($ts);
foreach my $r (@recvd) {
@@ -124,7 +130,7 @@ sub msg_received_at ($) {
}
sub msg_date_only ($) {
- my ($hdr) = @_; # Email::MIME::Header
+ my ($hdr) = @_; # PublicInbox::Eml
my @date = $hdr->header_raw('Date');
my ($ts);
foreach my $d (@date) {
@@ -142,7 +148,7 @@ sub msg_date_only ($) {
# Favors Received header for sorting globally
sub msg_timestamp ($) {
- my ($hdr) = @_; # Email::MIME::Header
+ my ($hdr) = @_; # PublicInbox::Eml
my $ret;
$ret = msg_received_at($hdr) and return time_response($ret);
$ret = msg_date_only($hdr) and return time_response($ret);
@@ -151,7 +157,7 @@ sub msg_timestamp ($) {
# Favors the Date: header for display and sorting within a thread
sub msg_datestamp ($) {
- my ($hdr) = @_; # Email::MIME::Header
+ my ($hdr) = @_; # PublicInbox::Eml
my $ret;
$ret = msg_date_only($hdr) and return time_response($ret);
$ret = msg_received_at($hdr) and return time_response($ret);