1
0

fix some DeprecationWarnings in python3.12

...\electrum\electrum\logging.py:137: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
...\electrum\electrum\x509.py:310: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
This commit is contained in:
SomberNight
2023-12-24 08:57:57 +00:00
parent 3d1009f7e2
commit d54184dbc1
4 changed files with 14 additions and 11 deletions

View File

@@ -17,7 +17,8 @@ from . import util
from .bitcoin import COIN
from .i18n import _
from .util import (ThreadJob, make_dir, log_exceptions, OldTaskGroup,
make_aiohttp_session, resource_path, EventListener, event_listener, to_decimal)
make_aiohttp_session, resource_path, EventListener, event_listener, to_decimal,
timestamp_to_datetime)
from .util import NetworkRetryManager
from .network import Network
from .simple_config import SimpleConfig
@@ -306,7 +307,7 @@ class CoinCap(ExchangeBase):
# (and history starts on 2017-03-23)
history = await self.get_json('api.coincap.io',
'/v2/assets/bitcoin/history?interval=d1&limit=2000')
return dict([(datetime.utcfromtimestamp(h['time']/1000).strftime('%Y-%m-%d'), str(h['priceUsd']))
return dict([(timestamp_to_datetime(h['time']/1000, utc=True).strftime('%Y-%m-%d'), str(h['priceUsd']))
for h in history['data']])
@@ -354,7 +355,7 @@ class CoinGecko(ExchangeBase):
history = await self.get_json('api.coingecko.com',
'/api/v3/coins/bitcoin/market_chart?vs_currency=%s&days=max' % ccy)
return dict([(datetime.utcfromtimestamp(h[0]/1000).strftime('%Y-%m-%d'), str(h[1]))
return dict([(timestamp_to_datetime(h[0]/1000, utc=True).strftime('%Y-%m-%d'), str(h[1]))
for h in history['prices']])
@@ -371,7 +372,7 @@ class Bit2C(ExchangeBase):
history = await self.get_json('bit2c.co.il',
'/Exchanges/BtcNis/KLines?resolution=1D&from=1357034400&to=%s' % int(time.time()))
return dict([(datetime.utcfromtimestamp(h[0]).strftime('%Y-%m-%d'), str(h[6]))
return dict([(timestamp_to_datetime(h[0], utc=True).strftime('%Y-%m-%d'), str(h[6]))
for h in history])