diff --git a/gcloud/datastore/helpers.py b/gcloud/datastore/helpers.py index 3eb1356d4d9d..fc814dcfd323 100644 --- a/gcloud/datastore/helpers.py +++ b/gcloud/datastore/helpers.py @@ -82,8 +82,9 @@ def get_value_from_protobuf(pb): if pb.value.HasField('timestamp_microseconds_value'): microseconds = pb.value.timestamp_microseconds_value - return (datetime.utcfromtimestamp(0) + - timedelta(microseconds=microseconds)) + naive = (datetime.utcfromtimestamp(0) + + timedelta(microseconds=microseconds)) + return naive.replace(tzinfo=pytz.utc) elif pb.value.HasField('key_value'): return Key.from_protobuf(pb.value.key_value) diff --git a/gcloud/datastore/test_helpers.py b/gcloud/datastore/test_helpers.py index 2606012779a8..139eb02a4784 100644 --- a/gcloud/datastore/test_helpers.py +++ b/gcloud/datastore/test_helpers.py @@ -100,9 +100,7 @@ def test_datetime(self): utc = datetime.datetime(2014, 9, 16, 10, 19, 32, 4375, pytz.utc) micros = (calendar.timegm(utc.timetuple()) * 1000000) + 4375 pb = self._makePB('timestamp_microseconds_value', micros) - # self.assertEqual(self._callFUT(pb), utc) XXX - # see https://github.com/GoogleCloudPlatform/gcloud-python/issues/131 - self.assertEqual(self._callFUT(pb), naive) + self.assertEqual(self._callFUT(pb), utc) def test_key(self): from gcloud.datastore.datastore_v1_pb2 import Property