Skip to content

Commit

Permalink
Fix parse_datetime to parse API datetime string format with Python 3.6
Browse files Browse the repository at this point in the history
The '%z' directive didn't accept 'Z' until Python 3.7
  • Loading branch information
Harmon758 committed Oct 28, 2021
1 parent e9a8298 commit 5bf2446
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tweepy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5bf2446

Please sign in to comment.