From the course: gRPC in Python
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Working with time
- Let's add the time to our start request. We are going to import Google protobuf Timestamp . proto which is the definition by Google of what is at timestamp. And in our start request we are now going to add a field called time which is of type google.protobuf . Timestamp. Let's generate the code. So protoc -- Python_out = rides . proto And now we can start using it. Note that the generated type is not Pythons daytime. It's a different type, and you need to do conversion back and forth every time. So we create a start request with all the fields not including the time field. And now we specify that this is a time. And then we set the request time field from daytime and we are going to print it out. If you have a Timestamp you can convert it to daytime using the two daytime method. And there is also a method to get the current time. So you can do Timestamp and you can do GetCurrentTime. Let's run this start without the…