def _humanize_time(amount, units):
intervals = (<NUM_LIT:1>, <NUM_LIT>, <NUM_LIT> * <NUM_LIT>, <NUM_LIT> * <NUM_LIT> * <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>)<EOL>names = (<EOL>("<STR_LIT>", "<STR_LIT>"),<EOL>("<STR_LIT>", "<STR_LIT>"),<EOL>("<STR_LIT>", "<STR_LIT>"),<EOL>("<STR_LIT>", "<STR_LIT>"),<EOL>("<STR_LIT>", "<STR_LIT>"),<EOL>("<STR_LIT>", "<STR_LIT>"),<EOL>("<STR_LIT>", "<STR_LIT>"),<EOL>)<EOL>result = []<EOL>unit = [x[<NUM_LIT:1>] for x in names].index(units)<EOL>amount = amount * intervals[unit]<EOL>for i in range(len(names) - <NUM_LIT:1>, -<NUM_LIT:1>, -<NUM_LIT:1>):<EOL><INDENT>a = int(amount) // intervals[i]<EOL>if a > <NUM_LIT:0>:<EOL><INDENT>result.append((a, names[i][<NUM_LIT:1> % a]))<EOL>amount -= a * intervals[i]<EOL><DEDENT><DEDENT>return result<EOL>
Chopped and changed from http://stackoverflow.com/a/6574789/205832