def prettydate(date):
    now = datetime.now(timezone.utc)
    """
    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.
    """
    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.