From e7ceda03356acc9579b50d745e6ab8120cdb677d Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Wed, 12 May 2021 08:32:11 -0400 Subject: Force datetime to UTC if it's native We always want the datetime object to be tz-aware, but certain Date: header formats result in timezone-naive variants. For those cases, just pretend it's UTC, as that's sufficiently accurate for our purposes. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/b4/__init__.py b/b4/__init__.py index 12afe94..61fe542 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -827,6 +827,9 @@ class LoreMessage: else: # An email without a Date: field? self.date = datetime.datetime.now() + # Force it to UTC if it's naive + if self.date.tzinfo is None: + self.date = self.date.replace(tzinfo=datetime.timezone.utc) diffre = re.compile(r'^(---.*\n\+\+\+|GIT binary patch|diff --git \w/\S+ \w/\S+)', re.M | re.I) diffstatre = re.compile(r'^\s*\d+ file.*\d+ (insertion|deletion)', re.M | re.I) -- cgit v1.2.3