unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/9] msgtime: quiet warnings we can do nothing about
Date: Wed, 11 Oct 2023 07:20:51 +0000	[thread overview]
Message-ID: <20231011072057.758022-4-e@80x24.org> (raw)
In-Reply-To: <20231011072057.758022-1-e@80x24.org>

In retrospect, warning about bad times and dates is pointless
since there's nothing actionable about it.  We'll also drop an
unnecessary capture in msg_received_at while we're at it and
favor using $eml since as the input variable name to match
current usage.

The note to install Date::Parse as a fallback remains since it
can be helpful in some cases (and is actionable by the user).
---
 lib/PublicInbox/MsgTime.pm | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/lib/PublicInbox/MsgTime.pm b/lib/PublicInbox/MsgTime.pm
index 5ee087fd..58b0deae 100644
--- a/lib/PublicInbox/MsgTime.pm
+++ b/lib/PublicInbox/MsgTime.pm
@@ -1,11 +1,11 @@
-# Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # Various date/time-related functions
 package PublicInbox::MsgTime;
+use v5.10.1; # unicode_strings in 5.12 may not work...
 use strict;
-use warnings;
-use base qw(Exporter);
+use parent qw(Exporter);
 our @EXPORT_OK = qw(msg_timestamp msg_datestamp);
 use Time::Local qw(timegm);
 my @MoY = qw(january february march april may june
@@ -125,10 +125,7 @@ sub str2date_zone ($) {
 	# but we want to keep "git fsck" happy.
 	# "-1200" is the furthest westermost zone offset,
 	# but git fast-import is liberal so we use "-1400"
-	if ($zone >= 1400 || $zone <= -1400) {
-		warn "bogus TZ offset: $zone, ignoring and assuming +0000\n";
-		$zone = '+0000';
-	}
+	$zone = '+0000' if $zone >= 1400 || $zone <= -1400;
 	[$ts, $zone];
 }
 
@@ -138,30 +135,22 @@ sub time_response ($) {
 }
 
 sub msg_received_at ($) {
-	my ($hdr) = @_; # PublicInbox::Eml
-	my @recvd = $hdr->header_raw('Received');
-	my ($ts);
-	foreach my $r (@recvd) {
+	my ($eml) = @_;
+	my $ts;
+	for my $r ($eml->header_raw('Received')) {
 		$r =~ /\s*([0-9]+\s+[a-zA-Z]+\s+[0-9]{2,4}\s+
 			[0-9]+[^0-9][0-9]+(?:[^0-9][0-9]+)
-			\s+([\+\-][0-9]+))/sx or next;
+			\s+(?:[\+\-][0-9]+))/sx or next;
 		$ts = eval { str2date_zone($1) } and return $ts;
-		my $mid = $hdr->header_raw('Message-ID');
-		warn "no date in $mid Received: $r\n";
 	}
 	undef;
 }
 
 sub msg_date_only ($) {
-	my ($hdr) = @_; # PublicInbox::Eml
-	my @date = $hdr->header_raw('Date');
-	my ($ts);
-	foreach my $d (@date) {
+	my ($eml) = @_;
+	my $ts;
+	for my $d ($eml->header_raw('Date')) {
 		$ts = eval { str2date_zone($d) } and return $ts;
-		if ($@) {
-			my $mid = $hdr->header_raw('Message-ID');
-			warn "bad Date: $d in $mid: $@\n";
-		}
 	}
 	undef;
 }

  parent reply	other threads:[~2023-10-11  7:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11  7:20 [PATCH 0/9] lei + import-related updates Eric Wong
2023-10-11  7:20 ` [PATCH 1/9] lei rediff: use ProcessIO for --drq support Eric Wong
2023-10-11  7:20 ` [PATCH 2/9] lei_xsearch: improve curl progress reporting Eric Wong
2023-10-11  7:20 ` Eric Wong [this message]
2023-10-11  7:20 ` [PATCH 4/9] msgtime: simplify msg_timestamp and msg_datestamp Eric Wong
2023-10-11  7:20 ` [PATCH 5/9] treewide: consolidate "From " line removal Eric Wong
2023-10-11  7:20 ` [PATCH 6/9] import: switch to Unix stream socket for fast-import Eric Wong
2023-10-11  7:20 ` [PATCH 7/9] import: cat_blob is a no-op w/o live fast-import Eric Wong
2023-10-11  7:20 ` [PATCH 8/9] lei blob: run cat_blob on lei/store for pending blobs Eric Wong
2023-10-11  7:20 ` [PATCH 9/9] lei import|tag|rm: support --commit-delay=SECONDS Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231011072057.758022-4-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).