def DatetimeValueFromString(value):
  """Converts a serialized datetime string to the native type.

  Args:
    value: The string value to be deserialized.

  Returns:
    A datetime.datetime/date/time object that was deserialized from the string.

  Raises:
    TypeError: if the value can not be deserialized to one of the three
        datetime types.
  """
  try:
    return datetime.datetime.strptime(value, TIME_STRING_FORMAT).time()
  except __HOLE__:
    pass

  try:
    return datetime.datetime.strptime(value, DATE_STRING_FORMAT).date()
  except ValueError:
    pass

  try:
    return datetime.datetime.strptime(value, DATETIME_STRING_FORMAT)
  except ValueError:
    pass

  raise TypeError('Could not deserialize timestamp: %s.' % (value,))
dataset/ETHPy150Open GoogleCloudPlatform/endpoints-proto-datastore/endpoints_proto_datastore/utils.py/DatetimeValueFromString