def time_ago(t, base=None):
    if not t:
        return ''

    delta = (base or datetime.datetime.utcnow()) - t
    duration = int(delta.total_seconds())
    days, seconds = delta.days, delta.seconds
    hours = seconds // 3600
    minutes = (seconds % 3600) // 60
    seconds = (seconds % 60)

    if duration < 0:
        return ''
    if duration < 60:
        return ' for {}s'.format(duration)
    if duration < 3600:
        return ' for {}m{}s'.format(minutes, seconds)
    if duration < 86400:
        return ' for {}h{}m'.format(hours, minutes)
    # Biggest step is by day.
    return ' for {}d{}h{}m'.format(days, hours, minutes)
Test if cache_local_file handles a nonexistent file.
dataset/ETHPy150Open signalfx/maestro-ng/maestro/termoutput.py/time_ago--crossover with--dataset/ETHPy150Open saltstack/salt/tests/unit/modules/cp_test.py/CpTestCase.test_cache_local_file_not_exists