def __contains__(self, x):
self.validate_time_inversion()<EOL>if isinstance(x, DateTimeRange):<EOL><INDENT>return x.start_datetime >= self.start_datetime and x.end_datetime <= self.end_datetime<EOL><DEDENT>try:<EOL><INDENT>value = dateutil.parser.parse(x)<EOL><DEDENT>except (TypeError, AttributeError):<EOL><INDENT>value = x<EOL><DEDENT>return self.start_datetime <= value <= self.end_datetime<EOL>
:param x:
    |datetime|/``DateTimeRange`` instance to compare.
    Parse and convert to |datetime| if the value type is |str|.
:type x: |datetime|/``DateTimeRange``/|str|
:return: |True| if the ``x`` is within the time range
:rtype: bool

:Sample Code:
    .. code:: python

        from datetimerange import DateTimeRange

        time_range = DateTimeRange("2015-03-22T10:00:00+0900", "2015-03-22T10:10:00+0900")
        print("2015-03-22T10:05:00+0900" in time_range)
        print("2015-03-22T10:15:00+0900" in time_range)

        time_range_smaller = DateTimeRange("2015-03-22T10:03:00+0900", "2015-03-22T10:07:00+0900")
        print(time_range_smaller in time_range)
:Output:
    .. parsed-literal::

        True
        False
        True

.. seealso::
    :py:meth:`.validate_time_inversion`