code: def _dayofmonth(hardday, month, year):
      '''
      Returns a valid day of the month given the desired value.
  
      Negative values are interpreted as offset backwards from the last day of the month, with -1 representing the
      last day of the month.  Out-of-range values are clamped to the first or last day of the month.
      '''
      newday = hardday
      daysinmonth = calendar.monthrange(year, month)[1]
      if newday < 0:
          newday = daysinmonth + hardday + 1
      newday = max(1, min(newday, daysinmonth))
      return newdaf _dayofmonth(hardday, month, year):
      '''
      Returns a valid day of the month given the desired value.
  
      Negative values are interpreted as offset backwards from the last day of the month, with -1 representing the
      last day of the month.  Out-of-range values are clamped to the first or last day of the month.
      '''
      newday = hardday
      daysinmonth = calendar.monthrange(year, month)[1]
      if newday < 0:
          newday = daysinmonth + hardday + 1
      newday = max(1, min(newday, daysinmonth))
      return newday
docs: Returns a valid day of the month given the desired value.
  
      Negative values are interpreted as offset backwards from the last day of the month, with -1 representing the
      last day of the month.  Out-of-range values are clamped to the first or last day of the month.