from dateutil.relativedelta import relativedelta


def human_readable_time(delta, terms=1):
    """Convert hours to human readable string

    Arguments:
        delta: time in seconds
        terms: how many word terms to use, to describe the timestep
    Returns
        str: Human readable string
    """
    # Inspired by http://stackoverflow.com/questions/26164671/convert-seconds-to-readable-format-time

    intervals = ['years', 'months', 'days', 'hours', 'minutes', 'seconds']
    if delta > 31:
        delta = delta
    rd = relativedelta(hours=delta)
    out = ""
    for k in intervals[:terms]:
        if getattr(rd, k):
            out += '{} {} '.format(getattr(rd, k), k)
    return out.strip()