Skip to content

Commit b1445d7

Browse files
Add back timestamp protobuf (GoogleCloudPlatform#6509)
* Add back timestamp protobuf * lint Co-authored-by: gcf-merge-on-green[bot] <60162190+gcf-merge-on-green[bot]@users.noreply.github.com>
1 parent 0ed4738 commit b1445d7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

appengine/flexible/tasks/create_app_engine_queue_task.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def create_task(project, queue, location, payload=None, in_seconds=None):
2222
"""Create a task for a given queue with an arbitrary payload."""
2323

2424
from google.cloud import tasks_v2
25+
from google.protobuf import timestamp_pb2
2526
import datetime
2627
import json
2728

@@ -59,7 +60,11 @@ def create_task(project, queue, location, payload=None, in_seconds=None):
5960

6061
if in_seconds is not None:
6162
# Convert "seconds from now" into an rfc3339 datetime string.
62-
timestamp = datetime.datetime.utcnow() + datetime.timedelta(seconds=in_seconds)
63+
d = datetime.datetime.utcnow() + datetime.timedelta(seconds=in_seconds)
64+
65+
# Create Timestamp protobuf.
66+
timestamp = timestamp_pb2.Timestamp()
67+
timestamp.FromDatetime(d)
6368

6469
# Add the timestamp to the tasks.
6570
task['schedule_time'] = timestamp

0 commit comments

Comments
 (0)