Facetwp date source converted to year choices

<?php

/**
 * Create a facet with Post Date (or any other date field)
 * Re-index after adding or updating this filter
 * For more options and/or using months (and years), see: 
 * https://facetwp.com/help-center/developers/hooks/indexing-hooks/facetwp_index_row/#create-a-month-year-facet
 */
add_filter( 'facetwp_index_row', function( $params, $class ) {
	if ( 'date_as_year' == $params['facet_name'] ) { // change "date_as_year" to name of your facet
		$raw_value = $params['facet_value'];
		$params['facet_value'] = date( 'Y', strtotime( $raw_value ) );
		$params['facet_display_value'] = $params['facet_value'];
	}
	return $params;
}, 10, 2 );