How do I modify the code below to have the week range from Thursday 12 PM Central Time Zone to the following Thursday 12 PM, so setting the Start date of the week to be Thursday and end week to be Thursday instead of the Sunday to Sunday?
Date startWeek = Date.Today().toStartofWeek();
System.debug(startWeek);
Date endWeek = Date.Today().toStartofWeek()+6;
System.debug(endWeek);
DateTime dt = DateTime.newInstance(System.today(),Time.newInstance(18,0,0,0));
String dayOfWeek = dt.format('u');
//How many days from current week's Thursday is the date?
Integer offset = Integer.valueOf(dayOfWeek) - 4;
//If it's before the current weeks' Thursday
if(offset < 0){
//Last Thursday should be start date - if you're 3 days away from the current Thursday, you're 4 days away from last thursday (7 days in a week)
startWeek = Date.Today() - (offset + 7);
endWeek = Date.Today() + math.abs(offset);
} else if (offset > 0) {
//If it's past current Thursday, apply the opposite logic of the other condition
startWeek = Date.Today() - offset;
endWeek = Date.Today() + (7 - offset);
} else {
//last condition is that today is Thursday
startWeek = Date.Today();
endWeek = Date.Today() + 7;
}