class_docstr: Describes how the time dimension for metrics should be constrained.
class_docstr_tok: ["Describes","how","the","time","dimension","for","metrics","should","be","constrained","."]
code: def intersection(
      self, other: TimeRangeConstraint
  ) -> TimeRangeConstraint:  # noqa: D
      # self is completely before the other
      if self.end_time < other.start_time:
          return TimeRangeConstraint.empty_time()
      # self starts before the start of other, and self ends within other
      elif (
          self.start_time
          <= other.start_time
          <= self.end_time
          <= other.end_time
      ):
          return TimeRangeConstraint(
              start_time=other.start_time,
              end_time=self.end_time,
          )
      # self starts before the start of other, and self ends after other
      elif (
          self.start_time
          <= other.start_time
          <= other.end_time
          <= self.end_time
      ):
          return other
      # self starts after the start of other, and self ends within other:
      elif (
          other.start_time
          <= self.start_time
          <= self.end_time
          <= other.end_time
      ):
          return self
      # self starts after the start of other, and self ends after other:
      elif (
          other.start_time
          <= self.start_time
          <= other.end_time
          <= self.end_time
      ):
          return TimeRangeConstraint(
              start_time=self.start_time,
              end_time=other.end_time,
          )
      # self is completely after other
      elif self.start_time > other.end_time:
          return TimeRangeConstraint.empty_time()
      else:
          raise RuntimeError(
              f"Unhandled case - self: {self} other: {other}"
          )
  
imports: from __future__ import annotations
  import datetime
  import logging
  from dataclasses import dataclass
  from typing import Optional
  import pandas
  from dbt_semantic_interfaces.dataclass_serialization import SerializableDataclass
  from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity
  from metricflow.time.time_granularity import offset_period
label_desc: Use image node_id 11 for calling the TimeRangeConstraint obj's underlying member method code with example usage: obj.intersection(other) and returns: TimeRangeConstraint, TimeRangeConstraint, other, self, TimeRangeConstraint, TimeRangeConstraint