flirror/utils.py
def prettydate(date: Union[datetime, float]) -> str:
    """
    Return the relative timeframe between the given date and now.
    e.g. 'Just now', 'x days ago', 'x hours ago', ...
    When the difference is greater than 7 days, the timestamp will be returned
    instead.
    """
    # TODO (felix): Make all dates timezone aware.
    # Currently, the dates are not stored with timezone awareness in the database.
    # (How can we do that?). Additionally, not all dates returned by external
    # APIs are timezone aware. Thus, for now just assume that everything is UTC.
    now = datetime.utcnow()
    if isinstance(date, float):
        date = datetime.utcfromtimestamp(date)
    diff = now - date
    # Show the timestamp rather than the relative timeframe when the difference
    # is greater than 7 days
    if diff.days > 7:
        return date.strftime("%d. %b %Y")
    return arrow.get(date).humanize()

    Return the relative timeframe between the given date and now.
    e.g. 'Just now', 'x days ago', 'x hours ago', ...
    When the difference is greater than 7 days, the timestamp will be returned
    instead.
    
Return the relative timeframe between the given date and now.
Return the relative timeframe between the given date and now .
def prettydate(date: Union[datetime, float]) -> str:
    now = datetime.utcnow()
    if isinstance(date, float):
        date = datetime.utcfromtimestamp(date)
    diff = now - date
    if diff.days > 7:
        return date.strftime("%d. %b %Y")
    return arrow.get(date).humanize()
def prettydate ( date : Union [ datetime , float ] ) -> str : now = datetime . utcnow ( ) if isinstance ( date , float ) : date = datetime . utcfromtimestamp ( date ) diff = now - date if diff . days > 7 : return date . strftime ( "%d. %b %Y" ) return arrow . get ( date ) . humanize ( )
Return the relative timeframe between the given date and now.
Return the relative timeframe between the given date and now .
"""
    Return the relative timeframe between the given date and now.
    e.g. 'Just now', 'x days ago', 'x hours ago', ...
    When the difference is greater than 7 days, the timestamp will be returned
    instead.
    """ # TODO (felix): Make all dates timezone aware. # Currently, the dates are not stored with timezone awareness in the database. # (How can we do that?). Additionally, not all dates returned by external # APIs are timezone aware. Thus, for now just assume that everything is UTC. # Show the timestamp rather than the relative timeframe when the difference # is greater than 7 days
date
Union[datetime, float]