def overlaps(pattern_a, pattern_b):
  """Returns a boolean indicating if two patterns are overlapped.

  Args:
    pattern_a: SimilarPattern or TimeSpan.
    pattern_b: SimilarPattern or TimeSpan.
  Returns:
    boolean indicating if the patterns are overlapped.
  """
  start_a = pattern_a.start_time
  start_b = pattern_b.start_time

  end_a = pattern_a.start_time + pattern_a.duration
  end_b = pattern_b.start_time + pattern_b.duration

  a_falls_in_b = start_b < end_a and end_a < end_b
  b_falls_in_a = start_a < end_b and end_b < end_a

  return a_falls_in_b or b_falls_in_a