code: def timedelta_to_duration(obj):
      
      minutes, hours, days = 0, 0, 0
      seconds = int(obj.total_seconds())
      if seconds > 59:
          minutes = seconds // 60
          seconds = seconds % 60
      if minutes > 59:
          hours = minutes // 60
          minutes = minutes % 60
      if hours > 23:
          days = hours // 24
          hours = hours % 24
      response = []
      if days:
          response.append('%sd' % days)
      if hours:
          response.append('%sh' % hours)
      if minutes:
          response.append('%sm' % minutes)
      if seconds or not response:
          response.append('%ss' % seconds)
      return "".join(response)
docs: Converts timedelta to duration
  
      >>> timedelta_to_duration(datetime.timedelta(0, 600))
      >>> "10m"