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