aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-05-12 08:32:11 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-05-12 08:32:11 -0400
commite7ceda03356acc9579b50d745e6ab8120cdb677d (patch)
tree0cab6feb3952f3a5515e350859c601f5038c50c5
parent3f036f9155c3b3098de269afed4ab438989943d4 (diff)
downloadb4-e7ceda03356acc9579b50d745e6ab8120cdb677d.tar.gz
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 <konstantin@linuxfoundation.org>
-rw-r--r--b4/__init__.py3
1 files changed, 3 insertions, 0 deletions
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)