import time


def format_ago(timestamp):
    """Return the human readable time elapsed since `timestamp`."""
    st = time.gmtime(time.time() - timestamp)
    if st.tm_year - 1970 > 1:
        return '{0} years ago'.format(st.tm_year - 1970)
    if st.tm_year - 1970 == 1:
        return 'a year ago'
    if st.tm_mon - 1 > 1:
        return '{0} months ago'.format(st.tm_mon - 1)
    if st.tm_mon - 1 == 1:
        return 'a month ago'
    if st.tm_mday - 1 > 1:
        return '{0} days ago'.format(st.tm_mday - 1)
    if st.tm_mday - 1 == 1:
        return 'a day ago'
    if st.tm_hour > 1:
        return '{0} hours ago'.format(st.tm_hour)
    if st.tm_hour == 1:
        return 'an hour ago'
    if st.tm_min > 1:
        return '{0} minutes ago'.format(st.tm_min)
    if st.tm_min == 1:
        return 'a minute ago'
    return 'just now'