From bda08319fc3c02561c82743267823c19bf3e9495 Mon Sep 17 00:00:00 2001 From: Philip Lundrigan Date: Tue, 30 May 2017 12:09:16 -0600 Subject: [PATCH] photos: return time zone aware datetime object --- pyicloud/services/photos.py | 6 ++++-- requirements.txt | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pyicloud/services/photos.py b/pyicloud/services/photos.py index d57a10b..7c67c3c 100644 --- a/pyicloud/services/photos.py +++ b/pyicloud/services/photos.py @@ -10,6 +10,7 @@ from pyicloud.exceptions import ( PyiCloudBinaryFeedParseError, PyiCloudPhotoLibraryNotActivatedErrror ) +import pytz from future.moves.urllib.parse import unquote from future.utils import listvalues, listitems @@ -213,8 +214,9 @@ class PhotoAsset(object): @property def created(self): - dt = datetime.fromtimestamp(self.data.get('createdDate') / 1000.0) - return dt.strftime('%Y-%m-%dT%H:%M:%SZ') + dt = datetime.fromtimestamp(self.data.get('createdDate') / 1000.0, + tz=pytz.utc) + return dt @property def dimensions(self): diff --git a/requirements.txt b/requirements.txt index fe0946b..fce7f80 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ keyrings.alt>=1.0,<2.0 click>=6.0,<7.0 six>=1.9.0 tzlocal +pytz certifi bitstring future