From bf428f58efbf7989d7771e9edb54fade1009a4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= <6774676+eumiro@users.noreply.github.com> Date: Wed, 30 Nov 2022 20:44:13 +0100 Subject: refactor: simplify __datetime_to_epoch --- mastodon/Mastodon.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index e0b9257..9e30429 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -3925,15 +3925,9 @@ class Mastodon: Assumes UTC if timezone is not given. """ - date_time_utc = None if date_time.tzinfo is None: - date_time_utc = date_time.replace(tzinfo=datetime.timezone.utc) - else: - date_time_utc = date_time.astimezone(datetime.timezone.utc) - - epoch_utc = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=datetime.timezone.utc) - - return (date_time_utc - epoch_utc).total_seconds() + date_time = date_time.replace(tzinfo=datetime.timezone.utc) + return date_time.timestamp() def __get_logged_in_id(self): """ -- cgit v1.2.3