def format_seconds(seconds):
 seconds_in_a_minute = 60
 seconds_in_an_hour = (seconds_in_a_minute * 60)
 seconds_in_a_day = (seconds_in_an_hour * 24)
 days = math.floor((seconds / seconds_in_a_day))
 hour_seconds = (seconds % seconds_in_a_day)
 hours = math.floor((hour_seconds / seconds_in_an_hour))
 minute_seconds = (hour_seconds % seconds_in_an_hour)
 minutes = math.floor((minute_seconds / seconds_in_a_minute))
 remaining_seconds = (minute_seconds % seconds_in_a_minute)
 seconds = math.ceil(remaining_seconds)
 human_readable = []
 if (days > 0):
  human_readable.append('{}d'.format(int(days)))
 if (hours > 0):
  human_readable.append('{}h'.format(int(hours)))
 if (minutes > 0):
  human_readable.append('{}m'.format(int(minutes)))
 if (seconds > 0):
  human_readable.append('{}s'.format(int(seconds)))
 return ''.join(human_readable)

def format_seconds ( seconds ) : seconds_in_a_minute = 60 seconds_in_an_hour = ( seconds_in_a_minute * 60 ) seconds_in_a_day = ( seconds_in_an_hour * 24 ) days = math . floor ( ( seconds / seconds_in_a_day ) ) hour_seconds = ( seconds % seconds_in_a_day ) hours = math . floor ( ( hour_seconds / seconds_in_an_hour ) ) minute_seconds = ( hour_seconds % seconds_in_an_hour ) minutes = math . floor ( ( minute_seconds / seconds_in_a_minute ) ) remaining_seconds = ( minute_seconds % seconds_in_a_minute ) seconds = math . ceil ( remaining_seconds ) human_readable = [ ] if ( days > 0 ) : human_readable . append ( '{}d' . format ( int ( days ) ) ) if ( hours > 0 ) : human_readable . append ( '{}h' . format ( int ( hours ) ) ) if ( minutes > 0 ) : human_readable . append ( '{}m' . format ( int ( minutes ) ) ) if ( seconds > 0 ) : human_readable . append ( '{}s' . format ( int ( seconds ) ) ) return '' . join ( human_readable )
format a count of seconds to get a [h:]m:ss string .