docs: def convert_duration(duration: datetime.timedelta,
                       units: str) -> Optional[float]:
      """
      Convert a ``datetime.timedelta`` object -- a duration -- into other
      units. Possible units:
  
          ``s``, ``sec``, ``seconds``
          ``m``, ``min``, ``minutes``
          ``h``, ``hr``, ``hours``
          ``d``, ``days``
          ``w``, ``weeks``
          ``y``, ``years``
      """
      if duration is None:
          return None
      s = duration.total_seconds()
      if units in ['s', 'sec', 'seconds']:
          return s
      if units in ['m', 'min', 'minutes']:
          return s / SECONDS_PER_MINUTE
      if units in ['h', 'hr', 'hours']:
          return s / SECONDS_PER_HOUR
      if units in ['d', 'days']:
          return s / SECONDS_PER_DAY
      if units in ['w', 'weeks']:
          return s / SECONDS_PER_WEEK
      if units in ['y', 'years']:
          return s / SECONDS_PER_YEAR
      raise ValueError("Unknown units: {}".format(units))