From d462440b512629fd8ef444ce105477fcab2ae6b1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 25 Nov 2019 05:24:54 +0000 Subject: msgtime: deal with strange minutes in TZ offsets I'm not sure if TZ minute offsets aside from '00' or '30' exist, but lets just deal with them properly when negative. Examples taken from various inboxes on lore.kernel.org. These are mostly message from spammers, but some are legitimate messages. --- lib/PublicInbox/MsgTime.pm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/PublicInbox/MsgTime.pm') diff --git a/lib/PublicInbox/MsgTime.pm b/lib/PublicInbox/MsgTime.pm index 58e11d72..7dec48ce 100644 --- a/lib/PublicInbox/MsgTime.pm +++ b/lib/PublicInbox/MsgTime.pm @@ -23,6 +23,10 @@ sub str2date_zone ($) { my $sign = ($off < 0) ? '-' : '+'; my $hour = abs(int($off / 3600)); my $min = ($off / 60) % 60; + + # deal with weird offsets like '-0420' properly + $min = 60 - $min if ($min && $off < 0); + my $zone = sprintf('%s%02d%02d', $sign, $hour, $min); # "-1200" is the furthest westermost zone offset, -- cgit v1.2.3-24-ge0c7