Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes a non-deterministic failing test in bigquery. #1029

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions gcloud/bigquery/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ def _datetime_from_prop(value):
"""
if value is not None:
# back-end returns timestamps as milliseconds since the epoch
value = datetime.datetime.utcfromtimestamp(value / 1000.0)
return value.replace(tzinfo=pytz.utc)
seconds = int(value / 1000.0)
microseconds = 1000.0 * (value - 1000 * seconds)
return (
_EPOCH +
datetime.timedelta(seconds=seconds, microseconds=microseconds)
)


def _prop_from_datetime(value):
Expand Down