Skip to content

Commit

Permalink
Fixed googleapis#50 - timestamps need to be int/long, not float.
Browse files Browse the repository at this point in the history
Finally fixed properly this time.
  • Loading branch information
jgeewax committed Feb 27, 2014
1 parent 2c26d9b commit d3f5b1b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gcloud/datastore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_protobuf_attribute_and_value(val):
"""

if isinstance(val, datetime):
name, value = 'timestamp_microseconds', time.mktime(val.timetuple())
name, value = 'timestamp_microseconds', long(time.mktime(val.timetuple()))
elif isinstance(val, Key):
name, value = 'key', val.to_protobuf()
elif isinstance(val, bool):
Expand Down
2 changes: 1 addition & 1 deletion gcloud/datastore/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_get_protobuf_value(self):
(long(), int()),
(float(), float()),
(bool(), bool()),
(now, time.mktime(now.timetuple())),
(now, long(time.mktime(now.timetuple()))),
(Key(), Key().to_protobuf()),
)

Expand Down

1 comment on commit d3f5b1b

@proppy
Copy link

@proppy proppy commented on d3f5b1b Feb 27, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the existing googledatastore does it a bit differently: https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/master/python/googledatastore/helper.py#L358

And the timestamp is in usec.

Please sign in to comment.