Migrate from pytz (#377)
This commit is contained in:
parent
cc631cdce7
commit
09fb9ba991
4 changed files with 16 additions and 18 deletions
|
@ -2,7 +2,7 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from calendar import monthrange
|
from calendar import monthrange
|
||||||
|
|
||||||
from tzlocal import get_localzone
|
from tzlocal import get_localzone_name
|
||||||
|
|
||||||
|
|
||||||
class CalendarService:
|
class CalendarService:
|
||||||
|
@ -27,7 +27,7 @@ class CalendarService:
|
||||||
(a calendar) and a guid (an event's ID).
|
(a calendar) and a guid (an event's ID).
|
||||||
"""
|
"""
|
||||||
params = dict(self.params)
|
params = dict(self.params)
|
||||||
params.update({"lang": "en-us", "usertz": get_localzone().zone})
|
params.update({"lang": "en-us", "usertz": get_localzone_name()})
|
||||||
url = f"{self._calendar_event_detail_url}/{pguid}/{guid}"
|
url = f"{self._calendar_event_detail_url}/{pguid}/{guid}"
|
||||||
req = self.session.get(url, params=params)
|
req = self.session.get(url, params=params)
|
||||||
self.response = req.json()
|
self.response = req.json()
|
||||||
|
@ -49,7 +49,7 @@ class CalendarService:
|
||||||
params.update(
|
params.update(
|
||||||
{
|
{
|
||||||
"lang": "en-us",
|
"lang": "en-us",
|
||||||
"usertz": get_localzone().zone,
|
"usertz": get_localzone_name(),
|
||||||
"startDate": from_dt.strftime("%Y-%m-%d"),
|
"startDate": from_dt.strftime("%Y-%m-%d"),
|
||||||
"endDate": to_dt.strftime("%Y-%m-%d"),
|
"endDate": to_dt.strftime("%Y-%m-%d"),
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ class CalendarService:
|
||||||
params.update(
|
params.update(
|
||||||
{
|
{
|
||||||
"lang": "en-us",
|
"lang": "en-us",
|
||||||
"usertz": get_localzone().zone,
|
"usertz": get_localzone_name(),
|
||||||
"startDate": from_dt.strftime("%Y-%m-%d"),
|
"startDate": from_dt.strftime("%Y-%m-%d"),
|
||||||
"endDate": to_dt.strftime("%Y-%m-%d"),
|
"endDate": to_dt.strftime("%Y-%m-%d"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,8 @@ import json
|
||||||
import base64
|
import base64
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
from pyicloud.exceptions import PyiCloudServiceNotActivatedException
|
from pyicloud.exceptions import PyiCloudServiceNotActivatedException
|
||||||
from pytz import UTC
|
|
||||||
|
|
||||||
|
|
||||||
class PhotosService:
|
class PhotosService:
|
||||||
|
@ -526,18 +525,18 @@ class PhotoAsset:
|
||||||
def asset_date(self):
|
def asset_date(self):
|
||||||
"""Gets the photo asset date."""
|
"""Gets the photo asset date."""
|
||||||
try:
|
try:
|
||||||
return datetime.fromtimestamp(
|
return datetime.utcfromtimestamp(
|
||||||
self._asset_record["fields"]["assetDate"]["value"] / 1000.0, tz=UTC
|
self._asset_record["fields"]["assetDate"]["value"] / 1000.0
|
||||||
)
|
).replace(tzinfo=timezone.utc)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return datetime.fromtimestamp(0)
|
return datetime.utcfromtimestamp(0).replace(tzinfo=timezone.utc)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def added_date(self):
|
def added_date(self):
|
||||||
"""Gets the photo added date."""
|
"""Gets the photo added date."""
|
||||||
return datetime.fromtimestamp(
|
return datetime.utcfromtimestamp(
|
||||||
self._asset_record["fields"]["addedDate"]["value"] / 1000.0, tz=UTC
|
self._asset_record["fields"]["addedDate"]["value"] / 1000.0
|
||||||
)
|
).replace(tzinfo=timezone.utc)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dimensions(self):
|
def dimensions(self):
|
||||||
|
|
|
@ -4,7 +4,7 @@ import time
|
||||||
import uuid
|
import uuid
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from tzlocal import get_localzone
|
from tzlocal import get_localzone_name
|
||||||
|
|
||||||
|
|
||||||
class RemindersService:
|
class RemindersService:
|
||||||
|
@ -24,7 +24,7 @@ class RemindersService:
|
||||||
"""Refresh data."""
|
"""Refresh data."""
|
||||||
params_reminders = dict(self._params)
|
params_reminders = dict(self._params)
|
||||||
params_reminders.update(
|
params_reminders.update(
|
||||||
{"clientVersion": "4.0", "lang": "en-us", "usertz": get_localzone().zone}
|
{"clientVersion": "4.0", "lang": "en-us", "usertz": get_localzone_name()}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Open reminders
|
# Open reminders
|
||||||
|
@ -76,7 +76,7 @@ class RemindersService:
|
||||||
|
|
||||||
params_reminders = dict(self._params)
|
params_reminders = dict(self._params)
|
||||||
params_reminders.update(
|
params_reminders.update(
|
||||||
{"clientVersion": "4.0", "lang": "en-us", "usertz": get_localzone().zone}
|
{"clientVersion": "4.0", "lang": "en-us", "usertz": get_localzone_name()}
|
||||||
)
|
)
|
||||||
|
|
||||||
due_dates = None
|
due_dates = None
|
||||||
|
|
|
@ -2,6 +2,5 @@ requests>=2.24.0
|
||||||
keyring>=21.4.0
|
keyring>=21.4.0
|
||||||
keyrings.alt>=3.5.2
|
keyrings.alt>=3.5.2
|
||||||
click>=7.1.2
|
click>=7.1.2
|
||||||
tzlocal==2.1
|
tzlocal>=4.0
|
||||||
pytz>=2020.1
|
|
||||||
certifi>=2020.6.20
|
certifi>=2020.6.20
|
||||||
|
|
Loading…
Reference in a new issue