def _datetime_to_pb_timestamp(when):
 ms_value = _microseconds_from_datetime(when)
 (seconds, micros) = divmod(ms_value, (10 ** 6))
 nanos = (micros * (10 ** 3))
 return timestamp_pb2.Timestamp(seconds=seconds, nanos=nanos)

def _datetime_to_pb_timestamp ( when ) : ms_value = _microseconds_from_datetime ( when ) ( seconds , micros ) = divmod ( ms_value , ( 10 ** 6 ) ) nanos = ( micros * ( 10 ** 3 ) ) return timestamp_pb2 . Timestamp ( seconds = seconds , nanos = nanos )
convert a datetime object to a timestamp protobuf .