code: def human_duration(t):
      
      if not isinstance(t, (int, float)):
          raise TypeError("human_duration() argument must be integer or float")
  
      chunks = (
        (60 * 60 * 24 * 365, u'years'),
        (60 * 60 * 24 * 30, u'months'),
        (60 * 60 * 24 * 7, u'weeks'),
        (60 * 60 * 24, u'days'),
        (60 * 60, u'hours'),
      )
  
      if t < 1:
          return u"%.1f ms" % round(t * 1000, 1)
      if t < 60:
          return u"%.1f sec" % round(t, 1)
      if t < 60 * 60:
          return u"%.1f min" % round(t / 60, 1)
  
      for seconds, name in chunks:
          count = t / seconds
          if count >= 1:
              count = round(count, 1)
              break
      return u"%(number).1f %(type)s" % {'number': count, 'type': name}
docs: Converts a time duration into a friendly text representation.
  
      >>> human_duration("type error")
      Traceback (most recent call last):
      ...
      TypeError: human_duration() argument must be integer or float
  
      >>> human_duration(0.01)
      u'10.0 ms'
      >>> human_duration(0.9)
      u'900.0 ms'
      >>> human_duration(65.5)
      u'1.1 min'
      >>> human_duration((60 * 60)-1)
      u'59.0 min'
      >>> human_duration(60*60)
      u'1.0 hours'
      >>> human_duration(1.05*60*60)
      u'1.1 hours'
      >>> human_duration(2.54 * 60 * 60 * 24 * 365)
      u'2.5 years'