Skip to content

Commit

Permalink
fix: Fix timestamp proto util to default to timestamp at call time. (#…
Browse files Browse the repository at this point in the history
…933)

* fix: Fix timestamp proto util to default to timestamp at call time.

* chore: lint
  • Loading branch information
sasha-gitg committed Dec 29, 2021
1 parent 1b7dbad commit d72a254
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions google/cloud/aiplatform/utils/__init__.py
Expand Up @@ -617,15 +617,17 @@ def _timestamped_copy_to_gcs(


def get_timestamp_proto(
time: Optional[datetime.datetime] = datetime.datetime.now(),
time: Optional[datetime.datetime] = None,
) -> timestamp_pb2.Timestamp:
"""Gets timestamp proto of a given time.
Args:
time (datetime.datetime):
Required. A user provided time. Default to datetime.datetime.now() if not given.
Optional. A user provided time. Default to datetime.datetime.now() if not given.
Returns:
timestamp_pb2.Timestamp - timestamp proto of the given time, not have higher than millisecond precision.
timestamp_pb2.Timestamp: timestamp proto of the given time, not have higher than millisecond precision.
"""
if not time:
time = datetime.datetime.now()
t = time.timestamp()
seconds = int(t)
# must not have higher than millisecond precision.
Expand Down

0 comments on commit d72a254

Please sign in to comment.