code: def intersection(self, x):
          
  
          self.validate_time_inversion()
          x.validate_time_inversion()
  
          if any([x.start_datetime in self, self.start_datetime in x]):
              start_datetime = max(self.start_datetime, x.start_datetime)
              end_datetime = min(self.end_datetime, x.end_datetime)
          else:
              start_datetime = None
              end_datetime = None
  
          return DateTimeRange(
              start_datetime=start_datetime,
              end_datetime=end_datetime,
              start_time_format=self.start_time_format,
              end_time_format=self.end_time_format,
          )
docs: Newly set a time range that overlaps
          the input and the current time range.
  
          :param DateTimeRange x:
              Value to compute intersection with the current time range.
  
          :Sample Code:
              .. code:: python
  
                  from datetimerange import DateTimeRange
                  dtr0 = DateTimeRange("2015-03-22T10:00:00+0900", "2015-03-22T10:10:00+0900")
                  dtr1 = DateTimeRange("2015-03-22T10:05:00+0900", "2015-03-22T10:15:00+0900")
                  dtr0.intersection(dtr1)
          :Output:
              .. parsed-literal::
  
                  2015-03-22T10:05:00+0900 - 2015-03-22T10:10:00+0900