You can use below JavaScript code to get the start date and end date of current week.
Date.prototype.getWeek = function(start)
{
//Calcing the starting point
start = start || 0;
var today = new Date(this.setHours(0, 0, 0, 0));
var day = today.getDay() - start;
var date = today.getDate() - day;
// Grabbing Start/End Dates
var StartDate = new Date(today.setDate(date));
var EndDate = new Date(today.setDate(date + 6));
return [StartDate, EndDate];
}
Use below in your custom date refinement template to get the start and end date of the week and update the search results:
var Dates = new Date().getWeek();
var fromValue =Dates[0].toISOString();
var toValue =Dates[1].toISOString();
// Create the refinement JSON value string
var refinement = '{"'+ ctx.RefinementControl.propertyName +'":["range('+fromValue +','+toValue +')"]}';
$getClientControl(this).updateRefinersJSON(refinement);