diff --git a/pyicloud/services/calendar.py b/pyicloud/services/calendar.py index a8c0a310..1c7687fc 100644 --- a/pyicloud/services/calendar.py +++ b/pyicloud/services/calendar.py @@ -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 @@ def get_event_detail(self, pguid, guid): (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 @@ def refresh_client(self, from_dt=None, to_dt=None): 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 @@ def calendars(self): 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"), } diff --git a/pyicloud/services/photos.py b/pyicloud/services/photos.py index 5808fab8..06b3dd32 100644 --- a/pyicloud/services/photos.py +++ b/pyicloud/services/photos.py @@ -3,9 +3,8 @@ 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 @@ def created(self): 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): diff --git a/pyicloud/services/reminders.py b/pyicloud/services/reminders.py index df37d89c..949586b3 100644 --- a/pyicloud/services/reminders.py +++ b/pyicloud/services/reminders.py @@ -4,7 +4,7 @@ import uuid import json -from tzlocal import get_localzone +from tzlocal import get_localzone_name class RemindersService: @@ -24,7 +24,7 @@ def refresh(self): """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 @@ def post(self, title, description="", collection=None, due_date=None): 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 diff --git a/requirements.txt b/requirements.txt index 5cf4b744..d6431767 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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