Skip to content

Commit

Permalink
force UTC timezone for timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoszek committed Nov 29, 2022
1 parent 8c0c51f commit 62502f1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pleroma_bot/_twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests

from tqdm import tqdm
from datetime import datetime
from datetime import datetime, timezone

from . import logger
from pleroma_bot.i18n import _
Expand Down Expand Up @@ -327,13 +327,13 @@ def _get_tweets(
response.raise_for_status()
tweets = response.json()
else: # pragma: todo
now_ts = int(datetime.utcnow().timestamp())
now_ts = int(datetime.now(tz=timezone.utc).timestamp())
fmt_date = ("%Y-%m-%dT%H:%M:%S.%fZ", "%Y-%m-%dT%H:%M:%SZ")
for fmt in fmt_date:
try:
start_time_ts = int(datetime.strptime(
start_time, fmt
).timestamp())
).replace(tzinfo=timezone.utc).timestamp())
except ValueError:
pass
query = (
Expand Down

0 comments on commit 62502f1

Please sign in to comment.