docs: def _encodeRelativeValidityPeriod(validityPeriod):
      """ Encodes the specified relative validity period timedelta into an integer for use in an SMS PDU
      (based on the table in section 9.2.3.12 of GSM 03.40)
      
      :param validityPeriod: The validity period to encode
      :type validityPeriod: datetime.timedelta
      :rtype: int
      """
      # Python 2.6 does not have timedelta.total_seconds(), so compute it manually
      #seconds = validityPeriod.total_seconds()
      seconds = validityPeriod.seconds + (validityPeriod.days * 24 * 3600)
      if seconds <= 43200: # 12 hours
          tpVp = int(seconds / 300) - 1 # divide by 5 minutes, subtract 1
      elif seconds <= 86400: # 24 hours
          tpVp = int((seconds - 43200) / 1800) + 143 # subtract 12 hours, divide by 30 minutes. add 143
      elif validityPeriod.days <= 30: # 30 days
          tpVp = validityPeriod.days + 166 # amount of days + 166
      elif validityPeriod.days <= 441: # max value of tpVp is 255
          tpVp = int(validityPeriod.days / 7) + 192 # amount of weeks + 192
      else:
          raise ValueError('Validity period too long; tpVp limited to 1 octet (max value: 255)')
      return tpVp