File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed
packages/google-cloud-core/google/cloud Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -439,16 +439,9 @@ def _timedelta_to_duration_pb(timedelta_val):
439439 :rtype: :class:`google.protobuf.duration_pb2.Duration`
440440 :returns: A duration object equivalent to the time delta.
441441 """
442- seconds_decimal = timedelta_val .total_seconds ()
443- # Truncate the parts other than the integer.
444- seconds = int (seconds_decimal )
445- if seconds_decimal < 0 :
446- signed_micros = timedelta_val .microseconds - 10 ** 6
447- else :
448- signed_micros = timedelta_val .microseconds
449- # Convert nanoseconds to microseconds.
450- nanos = 1000 * signed_micros
451- return duration_pb2 .Duration (seconds = seconds , nanos = nanos )
442+ duration_pb = duration_pb2 .Duration ()
443+ duration_pb .FromTimedelta (timedelta_val )
444+ return duration_pb
452445
453446
454447def _duration_pb_to_timedelta (duration_pb ):
You can’t perform that action at this time.
0 commit comments