def timestamp_custom(value, date_format=DATE_STR_FORMAT, local=True):
    'Filter to convert given timestamp to format.'
    try:
        date = dt_util.utc_from_timestamp(value)
        if local:
            date = dt_util.as_local(date)
        return date.strftime(date_format)
    except (ValueError, TypeError):
        return value
Filter to convert given timestamp to format.
def timestamp_custom(value, date_format=DATE_STR_FORMAT, local=True):
    
    try:
        date = dt_util.utc_from_timestamp(value)
        if local:
            date = dt_util.as_local(date)
        return date.strftime(date_format)
    except (ValueError, TypeError):
        return value