aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 2074224..e0b9257 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -11,7 +11,6 @@ import string
11import datetime 11import datetime
12import collections 12import collections
13from contextlib import closing 13from contextlib import closing
14import pytz
15import requests 14import requests
16from requests.models import urlencode 15from requests.models import urlencode
17import dateutil 16import dateutil
@@ -3928,11 +3927,11 @@ class Mastodon:
3928 """ 3927 """
3929 date_time_utc = None 3928 date_time_utc = None
3930 if date_time.tzinfo is None: 3929 if date_time.tzinfo is None:
3931 date_time_utc = date_time.replace(tzinfo=pytz.utc) 3930 date_time_utc = date_time.replace(tzinfo=datetime.timezone.utc)
3932 else: 3931 else:
3933 date_time_utc = date_time.astimezone(pytz.utc) 3932 date_time_utc = date_time.astimezone(datetime.timezone.utc)
3934 3933
3935 epoch_utc = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=pytz.utc) 3934 epoch_utc = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=datetime.timezone.utc)
3936 3935
3937 return (date_time_utc - epoch_utc).total_seconds() 3936 return (date_time_utc - epoch_utc).total_seconds()
3938 3937
@@ -3967,7 +3966,7 @@ class Mastodon:
3967 if v is not None: 3966 if v is not None:
3968 try: 3967 try:
3969 if isinstance(v, int): 3968 if isinstance(v, int):
3970 json_object[k] = datetime.datetime.fromtimestamp(v, pytz.utc) 3969 json_object[k] = datetime.datetime.fromtimestamp(v, datetime.timezone.utc)
3971 else: 3970 else:
3972 json_object[k] = dateutil.parser.parse(v) 3971 json_object[k] = dateutil.parser.parse(v)
3973 except: 3972 except:
@@ -4023,7 +4022,7 @@ class Mastodon:
4023 every time instead of randomly doing different things on some systems 4022 every time instead of randomly doing different things on some systems
4024 and also it represents that time as the equivalent UTC time. 4023 and also it represents that time as the equivalent UTC time.
4025 """ 4024 """
4026 isotime = datetime_val.astimezone(pytz.utc).strftime("%Y-%m-%dT%H:%M:%S%z") 4025 isotime = datetime_val.astimezone(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%S%z")
4027 if isotime[-2] != ":": 4026 if isotime[-2] != ":":
4028 isotime = isotime[:-2] + ":" + isotime[-2:] 4027 isotime = isotime[:-2] + ":" + isotime[-2:]
4029 return isotime 4028 return isotime
Powered by cgit v1.2.3 (git 2.41.0)