From e741807fb7776dec4caaa5a43dfb126864ed2fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 1 Jun 2023 22:08:09 +0300 Subject: [PATCH] Avoid `datetime.utcfromtimestamp` Python 3.12 deprecation warning https://docs.python.org/3.12/library/datetime.html#datetime.datetime.utcfromtimestamp --- pyicloud/services/photos.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pyicloud/services/photos.py b/pyicloud/services/photos.py index 06b3dd32..7d388638 100644 --- a/pyicloud/services/photos.py +++ b/pyicloud/services/photos.py @@ -525,18 +525,19 @@ def created(self): def asset_date(self): """Gets the photo asset date.""" try: - return datetime.utcfromtimestamp( - self._asset_record["fields"]["assetDate"]["value"] / 1000.0 - ).replace(tzinfo=timezone.utc) + return datetime.fromtimestamp( + self._asset_record["fields"]["assetDate"]["value"] / 1000.0, + timezone.utc, + ) except KeyError: - return datetime.utcfromtimestamp(0).replace(tzinfo=timezone.utc) + return datetime.fromtimestamp(0, timezone.utc) @property def added_date(self): """Gets the photo added date.""" - return datetime.utcfromtimestamp( - self._asset_record["fields"]["addedDate"]["value"] / 1000.0 - ).replace(tzinfo=timezone.utc) + return datetime.fromtimestamp( + self._asset_record["fields"]["addedDate"]["value"] / 1000.0, timezone.utc + ) @property def dimensions(self):