aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mastodon/Mastodon.py11
-rw-r--r--setup.py1
-rw-r--r--tests/test_status.py4
3 files changed, 7 insertions, 9 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
diff --git a/setup.py b/setup.py
index 1f03b30..29feedb 100644
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,6 @@ setup(name='Mastodon.py',
33 'requests>=2.4.2', 33 'requests>=2.4.2',
34 'python-dateutil', 34 'python-dateutil',
35 'six', 35 'six',
36 'pytz',
37 'python-magic', 36 'python-magic',
38 'decorator>=4.0.0', 37 'decorator>=4.0.0',
39 ] + blurhash_deps, 38 ] + blurhash_deps,
diff --git a/tests/test_status.py b/tests/test_status.py
index e747571..1fa7fd5 100644
--- a/tests/test_status.py
+++ b/tests/test_status.py
@@ -1,7 +1,7 @@
1import pytest 1import pytest
2from mastodon.Mastodon import MastodonAPIError, MastodonNotFoundError 2from mastodon.Mastodon import MastodonAPIError, MastodonNotFoundError
3import datetime 3import datetime
4import pytz 4import zoneinfo
5import vcr 5import vcr
6import time 6import time
7import pickle 7import pickle
@@ -154,7 +154,7 @@ def test_status_pin_unpin(status, api):
154 154
155@pytest.mark.vcr(match_on=['path']) 155@pytest.mark.vcr(match_on=['path'])
156def test_scheduled_status(api): 156def test_scheduled_status(api):
157 base_time = datetime.datetime(4000, 1, 1, 12, 13, 14, 0, pytz.timezone("Etc/GMT+2")) 157 base_time = datetime.datetime(4000, 1, 1, 12, 13, 14, 0, zoneinfo.ZoneInfo("Etc/GMT+2"))
158 the_future = base_time + datetime.timedelta(minutes=20) 158 the_future = base_time + datetime.timedelta(minutes=20)
159 scheduled_toot = api.status_post("please ensure adequate headroom", scheduled_at=the_future) 159 scheduled_toot = api.status_post("please ensure adequate headroom", scheduled_at=the_future)
160 assert scheduled_toot 160 assert scheduled_toot
Powered by cgit v1.2.3 (git 2.41.0)