def interval_encode(seconds, include_sign=False):
 s = ''
 orig = seconds
 seconds = abs(seconds)
 for (char, amount) in timeOrdered:
  if (seconds >= amount):
   (i, seconds) = divmod(seconds, amount)
   s += ('%i%s' % (i, char))
 if (orig < 0):
  s = ('-' + s)
 elif (not orig):
  return '0'
 elif include_sign:
  s = ('+' + s)
 return s

def interval_encode ( seconds , include_sign = False ) : s = '' orig = seconds seconds = abs ( seconds ) for ( char , amount ) in timeOrdered : if ( seconds >= amount ) : ( i , seconds ) = divmod ( seconds , amount ) s += ( '%i%s' % ( i , char ) ) if ( orig < 0 ) : s = ( '-' + s ) elif ( not orig ) : return '0' elif include_sign : s = ( '+' + s ) return s
encodes a number of seconds into a form like 1h2d3s .