def parse_time(time):
    """
    Parse a date/time string and return a corresponding datetime object.

    Args:
        time (str): A ``string` of one of the following formats: ``%H:%M``, ``%Y-%m-%d`` or
            ``%Y-%m-%d %H:%M``.

    Returns:
        datetime.datetime: Depending on input string either returns ``datetime.date``,
            ``datetime.time`` or ``datetime.datetime``.

    Raises:
        ValueError: If ``time`` can not be matched against any of the accepted formats.

    Note:
        This parse just a singlular date, time or datetime representation.
    """

    length = len(time.strip().split())
    if length == 1:
        try:
            result = datetime.datetime.strptime(time, '%H:%M:%S').time()
        except ValueError:
            try:
                result = datetime.datetime.strptime(time, '%H:%M').time()
            except ValueError:
                result = datetime.datetime.strptime(time, '%Y-%m-%d').date()
    elif length == 2:
        try:
            result = datetime.datetime.strptime(time, '%Y-%m-%d %H:%M:%S')
        except ValueError:
            result = datetime.datetime.strptime(time, '%Y-%m-%d %H:%M')
    else:
        raise ValueError(_(
            "String does not seem to be in one of our supported time formats."
        ))
    return result
Parse a date/time string and return a corresponding datetime object.

    Args:
        time (str): A ``string` of one of the following formats: ``%H:%M``, ``%Y-%m-%d`` or
            ``%Y-%m-%d %H:%M``.

    Returns:
        datetime.datetime: Depending on input string either returns ``datetime.date``,
            ``datetime.time`` or ``datetime.datetime``.

    Raises:
        ValueError: If ``time`` can not be matched against any of the accepted formats.

    Note:
        This parse just a singlular date, time or datetime representation.