From: Harmon Date: Thu, 28 Oct 2021 15:25:22 +0000 (-0500) Subject: Fix parse_datetime to parse API datetime string format with Python 3.6 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5bf24464b00257a9fa5f66047a2f7815c1e4f8fb;p=tweepy.git Fix parse_datetime to parse API datetime string format with Python 3.6 The '%z' directive didn't accept 'Z' until Python 3.7 --- diff --git a/tweepy/utils.py b/tweepy/utils.py index f11bcd0..4aa1c70 100644 --- a/tweepy/utils.py +++ b/tweepy/utils.py @@ -12,5 +12,6 @@ def list_to_csv(item_list): def parse_datetime(datetime_string): return datetime.datetime.strptime( - datetime_string, "%Y-%m-%dT%H:%M:%S.%f%z" - ) + datetime_string, "%Y-%m-%dT%H:%M:%S.%fZ" + ).replace(tzinfo=datetime.timezone.utc) + # Use %z when support for Python 3.6 is dropped