

def print_time_diff(diff):
    if (diff is None):
        return '?'
    if (diff < 0):
        return 'Negative Time'
    total_seconds = int(diff)
    days = (total_seconds // (24 * 3600))
    hours = ((total_seconds % (24 * 3600)) // 3600)
    minutes = ((total_seconds % 3600) // 60)
    seconds = (total_seconds % 60)

    def plural(number, name):
        return ('%d %s%s' % (number, name, ('' if (number == 1) else 's')))

    def pair(number1, name1, number2, name2):
        if (number2 > 0):
            return ('%s, %s' % (plural(number1, name1), plural(number2, name2)))
        else:
            return ('%s' % plural(number1, name1))
    if (days >= 1):
        return pair(days, 'day', hours, 'hour')
    elif (hours >= 1):
        return pair(hours, 'hour', minutes, 'minute')
    elif (minutes >= 1):
        return pair(minutes, 'minute', seconds, 'second')
    return plural(seconds, 'second')

dataset/ETHPy150Open NVIDIA/DIGITS/digits/utils/time_filters.py print_time_diff/original