docs: def _adjust_n_months(other_day, n, reference_day):
      """Adjust the number of times a monthly offset is applied based
      on the day of a given date, and the reference day provided.
      """
      if n > 0 and other_day < reference_day:
          n = n - 1
      elif n <= 0 and other_day > reference_day:
          n = n + 1
      return n