Allura/allura/lib/helpers.py
def ago(start_time, show_date_after=7):
    """
    Return time since starting time as a rounded, human readable string.
    E.g., "3 hours ago"
    """

    if start_time is None:
        return 'unknown'
    granularities = ['century', 'decade', 'year', 'month', 'day', 'hour',
                     'minute']
    end_time = datetime.utcnow()
    if show_date_after is not None and end_time - start_time > timedelta(days=show_date_after):
        return start_time.strftime('%Y-%m-%d')

    while True:
        granularity = granularities.pop()
        ago = date.distance_of_time_in_words(
            start_time, end_time, granularity, round=True)
        rounded_to_one_granularity = 'and' not in ago
        if rounded_to_one_granularity:
            break
    return ago + ' ago'

    Return time since starting time as a rounded, human readable string.
    E.g., "3 hours ago"
    
Return time since starting time as a rounded, human readable string.
Return time since starting time as a rounded human readable string .
def ago(start_time, show_date_after=7):
    if start_time is None:
        return 'unknown'
    granularities = ['century', 'decade', 'year', 'month', 'day', 'hour',
                     'minute']
    end_time = datetime.utcnow()
    if show_date_after is not None and end_time - start_time > timedelta(days=show_date_after):
        return start_time.strftime('%Y-%m-%d')
    while True:
        granularity = granularities.pop()
        ago = date.distance_of_time_in_words(
            start_time, end_time, granularity, round=True)
        rounded_to_one_granularity = 'and' not in ago
        if rounded_to_one_granularity:
            break
    return ago + ' ago'
def ago ( start_time , show_date_after = 7 ) : if start_time is None : return 'unknown' granularities = [ 'century' , 'decade' , 'year' , 'month' , 'day' , 'hour' , 'minute' ] end_time = datetime . utcnow ( ) if show_date_after is not None and end_time - start_time > timedelta ( days = show_date_after ) : return start_time . strftime ( '%Y-%m-%d' ) while True : granularity = granularities . pop ( ) ago = date . distance_of_time_in_words ( start_time , end_time , granularity , round = True ) rounded_to_one_granularity = 'and' not in ago if rounded_to_one_granularity : break return ago + ' ago'
Return time since starting time as a rounded, human readable string.
Return time since starting time as a rounded human readable string .
"""
    Return time since starting time as a rounded, human readable string.
    E.g., "3 hours ago"
    """
start_time
show_date_after