code: def strduration (duration):
      
      if duration < 0:
          duration = abs(duration)
          prefix = "-"
      else:
          prefix = ""
      duration = math.ceil(duration)
      if duration >= SECONDS_PER_HOUR: # 1 hour
          # time, in hours:minutes:seconds
          return "%s%02d:%02d:%02d" % (prefix, duration // SECONDS_PER_HOUR,
                                     (duration % SECONDS_PER_HOUR) // SECONDS_PER_MINUTE,
                                      duration % SECONDS_PER_MINUTE)
      else:
          # time, in minutes:seconds
          return "%s%02d:%02d" % (prefix, duration // SECONDS_PER_MINUTE,
                                   duration % SECONDS_PER_MINUTE)
docs: Turn a time value in seconds into hh:mm:ss or mm:ss.